If you’re using Google Analytics for website metrics and you only want to track real visitors, and not writers or authors. You can disable Google Analytics

This snippet automatically adds the Google Analytics code to your footer area (in case “wp_footer()” is called), so you don’t need to manually insert the Analytics code to all your theme files.

Add this snippet to your functions.php file located in your theme’s directory. You have to insert your Google Analytics id at “XXXXXXXX”.

add_action('wp_footer', 'wbcom_ga_for_loggedout');
function wbcom_ga_for_loggedout() {
 // not for logged in users
 if ( !is_user_logged_in() ) { ?>		
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-109127667-1']); // insert your Google Analytics id here
   _gaq.push(['_trackPageview']);
   _gaq.push(['_trackPageLoadTime']);
   (function() {
     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();
  <?php
 }
}

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Welcome to Wbcom Designs!  - Get 10% off on all plugins & themes
Coupon : HELLO10