Prevent Google Analytics from Tracking Admin Pages

Want to avoid Google Analytics from tracking your Admin pages? This handy snippet will prevent Google Analytics from tracking your Admin pages or anything else that you wish. Simply add this WordPress snippets after <body> starting tag

<?php if (!current_user_can('level_10')) { ?>
	/* Google Analytics Code */
<?php } ?>

level_10 is WordPress admin label
Now replace /* Google Analytics Code */ with your own Google Analytic codes.
This code will then include your Google Analytics code only on non-Admin pages. This in turn will prevent Google Analytics from gathering statistics about your Admin pages. Note that the basic functionality of this method is great for restricting just about anything — scripts, markup, content — to logged-in administrators.

Masum Billah has written 326 articles

Hi I am Md. Masum Billah Contributor of this website. I always like to share various things with other. In this website I am sharing web design related tips and tricks, necessary web development tools, source codes for beginner and advance web developer. You may join with us to help other who want to learn web design and development. Thank you for stay with.

Recommended Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>