Sunday, July 19, 2009

Blogger: Exclude Your Visits from Google Analytics

Google Analytics has a way of excluding certain visits to a site based on the presence of a special cookie. Many resources suggest that you create a "hidden" Web page to accomplish this, but that's difficult to do with Blogger. There is a workaround, however.

First, make sure you have Google Analytics installed and running on your blog.

Next, from each Web browser you use, pull up your blog. Once the page has fully loaded, enter the following javascript in the browser's location bar and press return/enter:
javascript:pageTracker._setVar('notrack');alert('cookie set');
That will set a "notrack" cookie on your browser.

Finally, sign into your Google Analytics account and create a custom filter to exclude all visitors that have the "notrack" cookie set. The filter values should be:

Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: notrack
Case Sensitive: No
Google Analytics should now begin ignoring your visits.

This approach isn't specific to Blogger; it should work on any site, including other blogging platforms such as Wordpress and Movable Type.

Also, to make it simpler to set the cookie, you may want to create a bookmark with the above javascript. Once added, simply go to your blog and select the bookmark.

Keywords: blogger ignore visits, blogger exclude, blogger hide


John said...

If this works, you should send it to Google together with a bill.
Why can't they just DO IT - HUH? I mean, Statcounter just DOES IT. Like "click here" and the cookie is set - how difficult is that!
Anyway, I appreciate your suggestion - it's by far the best I've seen for the Google/Blog problem - I'll try it immediately. Thanks ...

Leandro Arndt said...

Great trick! I couldn't find a way of doing this the way they say it should be done (although it used to work with the old version of the API). Now the cookie is set and I will try and see if it works.

Unknown said...

Thank you for this ! I hope it works. :))

Brad said...

Just tried this out, thanks for this simple trick!

Alsike Mat och Vin said...

I have tried everything. For hours. The suggestions from google, suggestions from other blogs about publishing html with tons of code. NONE OF IT WORKED. This worked in two seconds, thank you thank you thank you

GsariG said...

OK, if this works it's great!

One question though. Do I have to make the steps with exactly the order mentioned? What if I first create the filter and then add the cookie to the browser?

And one more question: does the cookie expire? Should I repeat the procedure after a period of time? Of course, I guess that after a format I should do it again anyway, right?

mla said...

@GsariG: Yes, you can create the filter before setting the cookie. The only place where order matters is to make sure the Google Analytics tracking code is installed on the blog before trying to set the cookie.

It looks like the notrack cookie expires after one year. If you clear your cookies periodically (or have security software that does), you'll also need to re-set it.

GsariG said...

@mla: thanks for the quick reply! I only use it for a day so far, but it seems to work.

This trick is exactly what I needed - you don't mess with the template and it's easy to apply.

Thanks alot! :)

Teddy said...

This is exactly what I need. Thank you. :)

Unknown said...

I'm trying this on my web site. I am hoping that entering the java code on the home page will cover the whole site. I'm with John, why can't all the brain power at google come up with a simple button like StatCounter has.
Thanks for this!!!

mla said...

@lostnbr: Yes, it will cover the whole site.

ClearSkyDomains said...

Hey, that's an excellent solution, and it's the main reason I hardly use Analytics anymore.

One question, does the cookie have to be named "notrack" or can the filter be set to ignore a different unique text string?

I mean if every domainer sets the same cookie we might lose some actual traffic stats we want to count also.

Thanks again for the great article!!

mla said...


Glad you found it helpful! :)

Yes, you can change the "notrack" name to anything you like. Just make sure the name is consistent between the cookie name and the filter value.

You shouldn't need to worry about losing stats. The cookie is set only on the domain you're currently viewing. So if you set the "notrack" cookie on your site, it won't be sent to other blogs/sites you visit.

The only situation where you'd lose stats is if your visitors set the notrack cookie /on your site/, which would be an odd thing for them to do unless they're actively trying to hide from you.

Reid said...

Thanks so much for posting this. It's very helpful.

Have you figured out a way to do this with the newer asynchronous code? I haven't found a setVar equivalent for it yet.

Jacob Lee said...

Go to your website, let it load completely. Then paste into your browser's location bar: javascript:_gaq.push(function() { pageTracker._setVar('youruniquefilterid'); }); alert('cookie set');

replacing the filter id of course.

Then create the filter in Google Analytics. That should do it.

social media agency said...

I have been looking for this kind of post for over a day now and I am just so glad that I found this post in this blog. I wish that it will also work in my blogger.