I want my own visits to not show in Google Analytics and for this I have added a test html page on my website. The idea is that I would hit this page once and GA should not count any of my visits in the analytics(by setting the opt_scope value in the _setCustomVar to "visitor" level). Following is the code snippet of my test html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xyz']);
_gaq.push(['_setCustomVar', 'myvisits', 'myvisits', 1]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
And, now in my Analytics I have set the following settings:
Filter Name: Myvisits
Filter Type: Custom filter
Exclude
Filter Field: User Defined
Filter pattern: myvisits
Case sensitive: No
Is there a way to verify whether my customvar is getting passed to GA. I tried to look into the request parameters to __utm.gif anf I could not see the "myvisits" variable getting passed. Here's the request details
http://www.google-analytics.com/__utm.gif?utmwv=4.8.9&utmn=485610273&utmhn=www.example.com&utmcs=ISO-8859-1&utmsr=1173x733&utmsc=24-bit&utmul=en-us&utmje=0&utmfl=10.1%20r85&utmhid=2133980375&utmr=-&utmp=%2Fplain.htm&utmac=xyz&utmcc=__utma%3D14266660.362063006.1299003679.1299003679.1299003679.1%3B%2B__utmz%3D14266660.1299003679.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B&utmu=q
Am I doing something wrong?
You forgot to add the index into your call to setCustomVar. Try:
_gaq.push(['_setCustomVar', 1, 'myvisits', 'myvisits', 1]);
I had to figure this out with my website as well. This link from google explains some ways to filter your visits. I'm not sure how good you want the filtering to work, but it seems like you can either install a cookie, or you can just have your ip address excluded. I tried to have a cookie installed that filtered my results but that didn't seem to work. Instead I decided to just go with filtering my ip since all of my visits to my site are from my home.
If you want to do it that way,
This method has worked for me since I don't need it to be perfect, but you may be looking for a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With