Thursday, January 8, 2009

How to stop Google Analytics from tracking your own visits


If you use Google Analytics to track visitors to your websites, it’s important to have Analytics filter out and exclude your own visits to your sites in order to get a true picture of your sites’ visitor count and demographic. You might be visiting a dozen pages on your site everyday and all these visits and page views can grossly inflate the visitor data of your sites. Unlike tracking services like Statcounter and Sitemeter, Google Analytics does not have an easy way of excluding your visits, particularly if you are on a dynamic IP.

If your net connection has a static IP, you can filter out that IP from being tracked. But if you are on a dynamic IP, like most of us are, you will need a different solution.

The solution is this: we will set a cookie on our browser and then use Analytics’ filter to ignore visits from all machines that has this cookie set. In order to create this cookie, create a page on your website with the following code on it.

If you use the old urchin tracker

<body onLoad=”javascript:__utmSetVar(’ignore_cookie_name’)”>

If you use the new Ga.js tracker

<body onLoad=”javascript:pageTracker._setVar('ignore_cookie_name')”>

Replace ignore_cookie_name with any name of your choice. The name should be unique because if any other visitor has a cookie of the same name, his visits will be ignored too. Throw in some random numbers to nullify any chance of somebody coincidentally naming their cookie the same.

The next step is the create a filter on Google Analytics. To do this, follow these steps:

  1. Click ‘Analytics Settings’ and then click on ‘Filter Manager’ at the bottom of the page.
  2. Click ‘Add Filter’
  3. On the Create New Filter page, create a new filter with the following settings:

    Filter Type: Custom filter > Exclude
    Filter Field: User Defined
    Filter Pattern: ignore_cookie_name (replace with actual name)
    Case Sensitive: No
  4. Under the ‘Apply Filter to Website Profiles’ section, select the website you want to apply this filter to.


The final step is to set this cookie on your browser. For this, simply visit the page having the JavaScript code. Make sure no visitors to your site has access to this page, otherwise the cookie will be set on their machines too.

To verify this is working correctly, place Analytics tracking code on this page and visit it a couple of times each day. Then try to find data about this page on Analytics report. If you can’t find any, it means that the ignore cookie is working. (Thanks AKA marketing)


  1. I have being updating lots and i only get a few visits so when i look and see 300 or more people on visits it dissapoints me to see that 150 were my own at least

  2. Or you could just block your ip address

  3. Great! I've tried to do this, but it never worked for me until now! Thanks!

  4. Damn! I wish I had seen this article about 3-4 weeks ago, as I just updated my own website's design, creating hundreds of my own visits >.<

    I will implement this for the future though, thanks!!!

  5. Great. Will do tonight on my sites.

  6. I use adblock plus with a special subscription ( It filters any webstats.

    Take Care

  7. This is really a new thing which i don't know till date. Till date, i am exclude all a complete section of c class IP to avoid my own clicks but i think that this trick would work for us .

    Thanks man

  8. Thanks for this article!
    I created a cookie page and visited it from work and home. When I checked the analytics, my visits from my work computer had been filtered out, but not the visits from my home computer. I can't figure out why they weren't added on that machine, when it worked on my work machine. Any advice would be much appreciated...

  9. @Kathryn: Definitely a cookie problem. Clear all cookies and try again. Also test with another browser.

  10. If your own visits distort total traffic stats that much do you really need GA?

  11. Nice tip!
    Well, I guess Adblock+ is enough.

    @Anonymous ;)

  12. How to use adblock to ignore my own clicks?

  13. @Chris: I'm not entirely sure, but users are probably blocking the Analytics tracking Javascript. But this would ignore all your visits across all sites that uses Analytics, something which I don't recommend.

  14. This is just taken from the Google Help pages:

    You also forget to mention that the tracking code must be on the cookie-page for this to work.

  15. The quotes in the article are special fancy quotes, which won't work if you copy and paste the code. Change the quotes to normal quotes (") and it should work.

  16. Long live clicky web analytics. Sets a special cookie, which does just this, in one click (from the web ui).

  17. Can you let me know how to set such cookies on blogger blog? I have one blogspot and I want to put such cookies. Can it be done?

    Let me know soon


  18. @Daily Poops: You can add the javascript code to the template between conditional tags like

    <b:if cond='data:post.url == "XYZ">

    where XYZ is the URL to the special cookie page you create in your blog.

    I haven't tried it so I cannot confirm whether it works.

  19. Why pick this over the ipadress filtering tool within google analytics?


  20. installing adblock plus 1.2 should also do the job

  21. How do I use this information to filter out my visits to my free blog hosted on ?

  22. Thank you so much. You saved me some time.

    BTW, Guys don't forget to replace the quotes (”) in the code above with normal quotes (")

  23. Hey this is the good post. I did not know about this. I just blocked my ip address. The above one is the another method. Great post. Thanks for sharing it... I would try it... :)

  24. Cool tip but I have to agree with this point:

    "If your own visits distort total traffic stats that much do you really need GA?"

    I think the only argument is that when you are trying to do design updates it can annoying.

  25. It worked pretty well for me! Thanks...

  26. Thanks. I was looking for same info. Thanks

  27. One part you did not mention is that when you create a filter, that filter is tied to one particular account -- Property ID: UA-XXXXXXXX-X. But a good number of us who use Google Analytics have multiple UA-XXXXXXXX-X accounts. So how do we easily exclude ourselves from all those accounts with a single cookie?


Popular Posts