Keeping yourself out of Google Analytics stats

Posted in Programming  
E-Mail This Post/Page   

A few months ago I wrote about a technique I use so that Adsense ads aren't shown to me when I'm viewing my sites. Recently I started doing the same with Google Analytics code so that I don't show up in my stats.

Yes, I know that Google has instructions for doing this but they assume a dedicated IP address which, because of a cable modem, do not have. It would be nice if there was some way to define a filter that worked on the user-agent string, and if anybody reading this knows how please add a comment. But barring that, I'm using my method.

Just swap out ABC below with whatever unique string you put in your query string.

PHP:
  1. if (strpos($_SERVER['HTTP_USER_AGENT'], 'ABC')!==false)
  2. {
  3. echo '<!--Hiding Analytics Code-->';
  4. }
  5. else
  6. {
  7. //    The full Google code
  8. echo '<script> (JS Code that Google gives you)</script>';
  9. }

Adsense Notifier Firefox Extension
Fly car on Google Maps
Google Desktop Search out of beta
Dilbert does Google
Google giving suggestions for searches

Leave a Comment