Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up an exclusion filter with a browser cookie, so that my own visits to my don't show up in my Google Analytics. I tried 3 different methods and none of them have worked so far. I would like help understanding what I am doing wrong and how I can fix this.

Method 1
First, I tried following Google's instructions, http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55481, for excluding traffic by Cookie Content:

Create a new page on your domain, containing the following code:

<body onLoad="javascript:pageTracker._setVar('test_value');">

Method 2
Next, when that didn't work, I googled around and found this Google thread, http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=4741f1499823fcd5&hl=en, where the most popular answer says to use a slightly different code:

SHS Analytics wrote:

 <body onLoad="javascript:_gaq.push(['_setVar','test_value']);">

Thank you! This has now set a __utmv cookie containing "test_value", whereas the original:


(which Google is still recommending) did not manage to do that for me (in Mac Safari 5 and Firefox 3.6.8).

So I tried this code, but it didn't work for me.

Method 3
Finally, I searched StackOverflow and came across this thread, http://stackoverflow.com/questions/3495270/exclude-my-traffic-from-google-analytics-using-cookie-with-subdomain, which suggests that the following code might work:

 <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setVar', 'exclude_me']);
    _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
 // etc...

This script appeared in the head element in the example, instead of in the onload event of the body like in the previous 2 examples. So I tried this too, but still had no luck with trying to exclude myself from Google Analytics.

Re-iterate question
So, I tried all 3 methods above with no success. Am I doing something wrong? How can I exclude myself from my Google Analytics using an exclusion cookie for my browser?

Update I've been testing this for several days now, and I've confirmed that the 2nd method of excluding yourself from tracking does indeed work. The problem was that the filter settings weren't properly applied to my profile, which has been corrected. See the accepted answer below.

share|improve this question
Why not just block your IP address? – John Conde Jun 19 '11 at 0:11
How long ago did you test these methods? It can take 24-48 hours for data to appear on Google Analytics. Secondly, did you add a cookie filter as described here: google.com/support/googleanalytics/bin/answer.py?answer=55494 ? – Niklas Jun 19 '11 at 0:12
@John I've tried that, it doesn't work, I just end up showing up in a nearby city...does that mean my ip address is dynamic? – 40XUserNotFound Jun 19 '11 at 0:13
most likely. If your IP addresses stay in a set range you can try blocking that range. – John Conde Jun 19 '11 at 0:14
@Niklas for the first method, I had tested it for days, so I'm pretty sure it doesn't work. As for the other two, I'm pretty sure I waited at least 24 hours to test the results, but just in case I'll go try them again and update what I find out here. – 40XUserNotFound Jun 19 '11 at 2:15
up vote 9 down vote accepted

There's nothing in your question about the second step of the process. The code you're using should just set a custom variable that will be sent to GA with the rest of the tracking data. You need to then set up a filter to exclude data where the variable is set to "test_value".

To create the filter , go to the "Analytics Settings > Profile Settings" screen and click on "Add Filter". In the screen that comes up use the following settings:

  • Add new Filter for Profile
  • Filter Name: Exclude own Traffic
  • Filter Type: Custom filter
  • Click the "exclude" radio button
  • Filter Field: User Defines
  • Filter Pattern: test_value
  • Case Sensitive: No

On a side note, remember that to set the custom variable you need to add the code to your page, run it then remove it. If you don't remove it then a cookie will be set for all visitors and they will all be excluded. It's best to set up an additional profile to test that the filter is working properly before applying it to your main profile as historical data can't be retrieved if you set it up wrong.

share|improve this answer
thanks for the answer, but I actually did set up the filter in my analytics profile, so that's not the problem. – 40XUserNotFound Jun 19 '11 at 3:22
OK, then you need to check out the cookies set in your browser to see if there's one called __utmv with a value of "test_value". Also check that there's not more than one set of cookies for your site as that can sometimes be a problem. – Ewan Heming Jun 19 '11 at 14:07
Another thing to try is checking out what's being sent to GA when you load a page. You can use something like the Firefox Live HTTP Headers addon or the Chrome GA Extension for this. Look to see if "test_value" is somewhere in the request for the __utm.gif file. – Ewan Heming Jun 19 '11 at 14:59
so it turns out that I either (1) never had the filter set up properly in my profile, or (2) the filter settings never transferred over to the new Analytics interface. I have a feeling it's the latter case, since I'm pretty sure I set up the filter properly in the old interface, using the instructions you mentioned above and that I mentioned in method 1 of my problem. Anyway, the point is, I went back to check the settings in the new interface, and it turned out that the filter wasn't there :/ I added it, and now it works with the 2nd method code I mentioned above. – 40XUserNotFound Jun 28 '11 at 2:24
Also note that google analytics Real-Time beta appears to ignore filters, or at least it takes a while for filters to work. See productforums.google.com/d/msg/analytics/ahnkTQ0QuRk/… – Adam Monsen Aug 16 '12 at 19:39

A way to do it without cookies is by using an extension: http://www.igorware.com/extensions/block-yourself-from-analytics I like this because

  • I have the extension installed in Chrome so it is available across my devices
  • it is easy to setup
  • I don't need to create a hidden page that sets the cookie or change a real page temporarily.
  • If I erase my cookies I don't need to remember to re-enable them.
share|improve this answer
is there somthing like this for firefox, i see the one you've linked too works for chrome, safari, opera – sam Dec 2 '12 at 19:35
the comments of the plugin suggest that it's no longer working – Philipp Keller Jun 6 '14 at 13:21
Thanks for the comment @PhilippKeller I verified I have 2.3.0 installed working (it works by preventing a download of the ga.js file) – David Silva Smith Jun 6 '14 at 15:51
so you confirmed that it is indeed working also for the new ga? – Philipp Keller Jun 7 '14 at 13:03
@PhilippKeller I checked and it doesn't seem to be working on the new Google analytics. It seems to be because the new version uses analytics.js not ga.js. – David Silva Smith Jun 8 '14 at 12:40

This is Google's official plugin for all the most common browsers, which will exclude you from Google Analytics:


Have all your team members install it.

PS: The issue with the IP-based filtering method is dynamic IP address allocation.

share|improve this answer
This has no way of only including certain domains as of today's version 0.9.6. You're shutting yourself out of analytics on everything. – lkraav May 30 '14 at 11:08
although there are no options to only blog GA for certain domains that's ok for me since I have many sites where I don't want to track myself – Philipp Keller Jun 6 '14 at 13:22

A quick and easy fix if you're using Firefox and don't want to mess your source code: Get the noscript add-on mark "google-analytics.com" as untrusted. This will prevent Firefox from executing the tracker, and your visits won't show up in your stats, or any other website's stats for that matter.

share|improve this answer
While this is one solution, it's not an ideal solution...I'd like one that will work for all browsers. But thanks for the answer. – 40XUserNotFound Jun 20 '11 at 5:32
There's a similar extension available for Chrome, ScriptSafe. – Saposhiente Mar 26 '15 at 8:17

A quick and dirty way to stop all tracking on all sites is to edit your hosts file C:\Windows\System32\drivers\etc\hosts and add these entries.

You'll probably need to restart your browser after changing them.       www.google-analytics.com       ssl.google-analytics.com

You don't need to go editing filters on google's site. Of course this method is mostly useless if you have many users you need to exclude and it means you can't use the Google Analytics Debugger Chrome Plugin which I highly recommend for testing (it's publiched by Google).

share|improve this answer
Better to use in most cases so a valid response is returned. – Simon Hayter Feb 28 '13 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.