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, https://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.

  • 2
    Why not just block your IP address?
    – John Conde
    Jun 19, 2011 at 0:11
  • 1
    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, 2011 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? Jun 19, 2011 at 0:13
  • most likely. If your IP addresses stay in a set range you can try blocking that range.
    – John Conde
    Jun 19, 2011 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. Jun 19, 2011 at 2:15

8 Answers 8


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.

  • thanks for the answer, but I actually did set up the filter in my analytics profile, so that's not the problem. Jun 19, 2011 at 3:22
  • 1
    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. Jun 19, 2011 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. Jun 19, 2011 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. Jun 28, 2011 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/… Aug 16, 2012 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.
  • is there somthing like this for firefox, i see the one you've linked too works for chrome, safari, opera
    – sam
    Dec 2, 2012 at 19:35
  • the comments of the plugin suggest that it's no longer working
    – hansaplast
    Jun 6, 2014 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) Jun 6, 2014 at 15:51
  • so you confirmed that it is indeed working also for the new ga?
    – hansaplast
    Jun 7, 2014 at 13:03
  • 1
    @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. Jun 8, 2014 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.

  • 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, 2014 at 11:08
  • 2
    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
    – hansaplast
    Jun 6, 2014 at 13:22
  • 1
    You can define which site shall be untracked in the extension details options - on specific sites only techrbun.com/prevent-self-tracking-in-google-analytics Apr 16, 2021 at 7:38

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.

  • 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. Jun 20, 2011 at 5:32
  • There's a similar extension available for Chrome, ScriptSafe.
    – Vitruvie
    Mar 26, 2015 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).

  • Better to use in most cases so a valid response is returned. Feb 28, 2013 at 23:29

If you are using Chrome only, use this:



Such task have to be solved by Google Analytics filters feature.

I recommend to take a look on this article - there are a few other Google Analytics filters which can be useful:


For example, I recommend also to add filter which is excluding staging traffic (people often forget about this). You can do this in the following way:

  • Filter Name: Exclude Dev Site Traffic
  • Filter Type: Custom > Exclude
  • Filter Field: Hostname
  • Filter Pattern: Enter a regex pattern of all development hostnames for your website. For example, if the development hostnames are dev.example.com, backend.example.com, and stage.example.com you would enter ^dev.example.com$|^backend.example.com$|^stage.example.com$ in this field (or some similar Regex).

Another recommended filter - Lowercase domain (hostname):

  • Filter Name: Lowercase Hostname
  • Filter Type: Custom > Lowercase
  • Filter Field: Hostname

And the last one - lowercase request uri:

  • Filter Name: Lowercase Request URI
  • Filter Type: Custom > Lowercase
  • Filter Field: Request URI

For anyone that wonders, you can just delete your client id to clean up your analytics data.

Go to Audience -> User explorer. It's a record of all user sessions. My user had a huge session duration. Once you spot the anomaly, click on the user and on the bottom of the page, left side, you will find a delete button. Data will be fixed in 3 days.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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