May 30, 2010

Excluding self traffic from Google Analytics data

Google Analytics lets you track how your site is used, which is great.  But did you know that the data Analytics reports includes your own visits too?  You probably wouldn't your own visits to your site to be included in the Analytics data.  Analytics Help Center has an article detailing how this could be done.  This post tries to add some clarity to the "To exclude traffic by Cookie Content" section of that help article.

Depending on which version of tracking code you are using on your site, you have to do this in different ways.  If your tracking code has the line
var pageTracker = _gat._getTracker('UA-xxxxxxx-x');
then you can follow the instructions provided in Google Analytics Help Center and everything should work fine.  However, if your tracking code has the line
var _gaq = _gaq || [];
then change your HTML file to contain this code instead:
<body onLoad="javascript:_gaq.push(['_setVar', 'test_value']);">
Pro Tip: You don't really have to create new HTML file on your site for setting the cookie.  You can just open your site on the browser and type the value of onLoad attribute in the address bar.  For example, in my case, I opened on my browser; typed javascript:_gaq.push(['_setVar', 'test_value']); on the address bar and pressed Enter.

No comments:

Post a Comment