Filter yourself from google analytics

Ramblings » Trackback-URL Add comments

If you use google analytics on your blog, here is a small clue on how to get your own visits to your blog filtered for it.
As a blogger, you will probably visit your own site very often, to answer comments or check design tweaks or what ever.

All these hits are being tracked by analytics by default. But with this little trick, you can trigger the analytics code only when another user visits your blog, but not when you visit it.

Put this to your footer.php just before the </body>-Tag.

<?php
get_currentuserinfo() ;
global $user_level;
if ($user_level != 10) {
echo'
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-XXXXXX-X“;
urchinTracker();
</script>
‘;
}
?>

And replace the XXXXXX-X with your actual analytics-ID. From now on, every time when you visit your blog, while you are logged in as an admin, the analytics code won´t be triggered.

The if ($user_level != 10) checks, whether the visitor is an admin (WordPress-UserLevel = 10).

Thank you for visiting my blog. There are new posts here every day. Staying updated is easy: Just subscribe to my RSS feed or subscribe to FREE eMail updates. Thanks for visiting!



Enjoyed this article?
Please subscribe to my RSS Feed!


Subscribe by Email
Get notified by email  on every new article!



Tags google analytics

The Latest From the Top Blogs About Blogging...

3 Responses to “Filter yourself from google analytics”

  1. Neil Galloway Says:

    Good suggestion. I have used this for awhile myself (a bit different code for me). Is this for Wordpress? Also, I think this implies that you are logged in for it to not trigger Analytics, so your own visits to the home page will still trigger a few extra visits.

  2. Marco Says:

    Neil, you´re right. This works for WordPress and you have to be logged in. Most of the time, when I do visit my blog, I am logged in.

Leave a Reply

1 Trackback so far

  1. Great SEO Tips at MarcoRichter.net | Learn SEO | SEO Techniques and Tools

    […] Filter yourself from google analytics: Shows you how to filter out your own blog visits so your google analytics provides a more accurate count of your visitors. […]

N.Design Studio
Entries RSS Comments RSS