02 April 2010

Exclude personal traffic from Google Analytics reports

Ever since I started measuring my blog traffic with Google Analytics, I wanted to filter out my own visits. This could seem like a minor issue, but if you have a relatively small number of visits your activity on the blog can skew the results pretty quickly, like when you test changes to the template. Until recently, the solutions from Google Analytics were impractical: I have a dynamic IP address, so the first option was excluded from the start. And in you couldn’t create a private page for the JavaScript required for the advanced filtering alternative.

After Blogger launched their native ‘Pages’ feature, the problem finally has a fairly easy solution. In your Blogger dashboard, create a new page, switch to the ‘Edit HTML’ tag and paste the JavaScript code from Google Analytics with a custom string, lets say “filteroutGA”. This code sets a custom cookie in your browser containing that string. Since you don’t want anyone else to have the cookie, after publishing it use the ‘Pages’ widget to hide it from your audience (just uncheck it from the list) and make sure you don’t link to it from other pages or articles.  Blogger page to exclude visits in Google Analytics

Next switch to the Google Analytics dashboard and create a custom filter, like explained on this help page. The filter will look for visits with the custom cookie set before and remove them from the reports. Use the same string in the ‘Filter Pattern’ field, in this case “filteroutGA”. Google Analytics exclude filter

And with that, the setup is done! Just keep in mind that this works only as long as you don’t erase your cookies or visit the blog from another browser. I think the best way to ensure you always have this excluding cookie present is to bookmark this special page and start each blog visit through that bookmark.

There could be another potential problem: if this “secret” page is indexed by search engines and shows up in search results, people visiting it will also get the cookie and disappear from Google Analytics reports. Since the page isn’t linked from anywhere I think it’s unlikely it will get crawled, but to be on the safe side, you should instruct search engines to ignore it. Using robots.txt is unfortunately not an option, because you can’t upload files on Blogger, but you can use a meta tag instead. In order to do this, edit the HTML template of your blog and add the following code inside the <head> section:

<b:if cond='data:blog.url == "http://your-secret-page-URL"'> <meta content='noindex' name='robots'/> </b:if>

This restricts the meta tag to “your-secret-page-URL”, allowing the rest of the blog to be visible to search engines as usual.


  1. Very nice post with clear step-by-step instructions. I don't have a dynamic IP but this is good information for me to share with other Blogger users. Thanks!

  2. First of all, thanks for these clear, thorough step by step instructions. Google was really starting to frustrate me with how spotty and incomplete a lot of their directions are.
    Secondly, I'm not entirely sure what I'm doing wrong, but I've installed the cookie, installed the filter, and I'm still showing up on my own analytics. Specifically, visits to the page with the cookie on it. Any suggestions?

  3. I also found the method to be not very reliable; it works for some time, then stops, even without clearing the browser cookies.
    I think it would be best to take advantage of a tool Google released in the mean time, an extension to block Google Analytics, found here: Google Analytics Opt-out Browser Add-on. It will block GA across all sites, not just your own, but it could be useful if you have a back-up browser where you do the writing and browsing for your own blog. Alternatively, there is an extension for Opera which can block GA specifically for your site(s): Block Yourself from Analytics. Hope this helps!

  4. I'd still like to show up on other people's analytics, but it's the best solution I've seen. I'll give it a try. Thanks again for all your help!