02 May 2009

Filtering Your Own Visits in Analytics

::
If you are using Google Analytics for statistics in your own site, you will most likely want to exclude your own visits from showing up by a filter. Google has provided two ways to achieve it:
  • By filtering out your IP 
  • By placing a cookie 

Both works OK but what if you have a dynamic IP and not a static site, i.e. a blog? The following method is for people who have blogs on blogspot domains:

  1. Create a backdated post using the scheduling feature so that the post is not easily spotted; take note of the URL for step four.
  2. Do not link to this post under any circumstances.
  3. Now comes the tricky part: Find the following section in your template by clicking "Edit HTML" tag.

    </head>
    your code will go here
    <body>
    ...

  4. Now insert the following code between the closing head and opening body tags:

    </head>
     <b:if cond='data:blog.url == &quot;YOUR-URL-GOES-HERE&quot;'>
      <body onLoad='javascript:pageTracker._setVar(&quot;test_value&quot;);'>
      </body>
     </b:if>
    <body>

  5. Save your template and visit the page. Check the source code if the body tag really contains the onLoad function.
  6. Go to your Analytics page and create a filter as per Google's instructions.
Everything should hopefully be OK, now.

Short URL for this post


4 comments:

  1. Wow this is an excellent and well written how-to! Thank you so much! I am about to do this on my blog and will see how it goes!

    ReplyDelete
  2. It does work for me, here. A word of caution: The default view in Analytics is monthly. Switch to daily to see if it really ignores your own visits as your previous visits will show up in the monthly view for another 30 days.

    ReplyDelete
  3. Nice article, probably helpful to blogspot users, and even the Google Instructions work for Wordpress users.

    ReplyDelete
  4. Google's instructions are written with static sites in mind. As I have a dynamic IP and blogs on blogspot domains, I simpy documented what I had done in the hopes that it would be useful who had similar constraints.

    ReplyDelete