Dukeo » WordPress » WordPress Admin & Google Analytics: How To Stop Tracking Me

WordPress Admin & Google Analytics: How To Stop Tracking Me

Steven 2 responses WordPress

If you want to have relevant analytics datafor your WordPress blog, you might want to prevent WordPress admin to be tracked by Google Analytics.

In order to do that, you need to check the level of the current user and display your analytics code only if the current user is not an admin. This is easily done with the function: current_user_can().

To implement this feature, you need to edit the file in your theme folder that includes your tracking code (either header.php or footer.php) and paste the following code:

<?php if (!current_user_can('level_10')) { ?>
<?php } ?>

If you enjoyed this article,
Get email updates

Join for Free »


  1. Hi, You can also create a filter in GG analytics interface and prevent the admin IP from being taken account.

    1. Thanks for sharing.

      This may sound like a good idea but this only works if you have a static IP and always visit your blog from the same place.

      I tend to use my laptop to work from various places, so your solution wouldn’t work for me.