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.

analytics-cookie

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)

28 comments:

interimjustia said...

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

Jon said...

Or you could just block your ip address

Colton said...

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

Kate said...

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!!!

Arthur K said...

Great. Will do tonight on my sites.

Anonymous said...

I use adblock plus with a special subscription (http://adblockplus.org/en/subscriptions). It filters any webstats.

Take Care
Tobi

Arvind said...

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

Kathryn said...

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...

Kaushik said...

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

Anonymous said...

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

Kaushik said...

@Anonymous: Good point! :^)

ArpitNext said...

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

@Anonymous ;)

Chris said...

How to use adblock to ignore my own clicks?

Kaushik said...

@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.

Anonymous said...

This is just taken from the Google Help pages: https://www.google.com/support/googleanalytics/bin/answer.py?answer=55481&hl=en_US&utm_id=ad

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

Anonymous said...

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.

Thomas said...

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

Daily Poops said...

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

Thanks

Kaushik said...

@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.

@strangeloops said...

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

@strangeloops

michkhoo said...

installing adblock plus 1.2 should also do the job

Anonymous said...

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

What Is My IP Address said...

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 (")

TriForce said...

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... :)

Blogging TIps said...

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.

Anonymous said...

It worked pretty well for me! Thanks...

Ayush Gupta said...

Thanks. I was looking for same info. Thanks

JDW said...

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?

Post a Comment