How do you exclude yourself from Google Analytics on your website using cookies?
Posted
by
Cold Hawaiian
on Pro Webmasters
See other posts from Pro Webmasters
or by Cold Hawaiian
Published on 2011-06-18T23:58:11Z
Indexed on
2012/09/18
15:54 UTC
Read the original article
Hit count: 348
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:
pageTracker._setVar('test_value')
(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']);
_gaq.push(['_trackPageview']);
// etc...
</script>
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.
© Pro Webmasters or respective owner