This article describes what to do, in order to exclude your visits from Google analytics if you are using the new asynchronous tracking Google code. i.e. you've got a website, and you want to be able to test it after you've launched it, or updated certain pages, and you don't want these visits / this traffic appearing in your Google Analytics stats / metrics.
First you need to create a html page on your website that looks something like this. Make sure only you know the address, and those testers who's traffic you want excluded from Google Analytics.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Exclude my Browser from stats page</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9999999-9']);
_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);
})();
</script>
</head>
<body onload="javascript:_gaq.push(['_setVar', 'exclude_browser_kevsapps']);">
<p style="font: 100% Verdana, Arial, Helvetica, sans-serif">Your browser is now excluded from the Analytics for you website. Thank you for setting the cookie you animal!>/p>
</body>
</html>
Please note the code hilighted in blue needs to be replaced with the google tracking id for your website. Note that as a pre-requisit I am assuming you've got the Google Analytics asynchronous tracking code on your website. If not follow the instructions here to set the cookie using the synchronous tracking code. This code should be identicle to the tracking code you currently have in your header.
The text in blue is the name of the cookie you are going to set which will exclude the traffic from google analytics. Note that you should call this something relevant to the fact it will exclude internal traffic from your site
The code in body onload attribute, pushing the setVar call to the Google Analytics code, this will set the cookie in the browser.
Once you've uploaded the page to your website, visit the page, and the cookie will be set for your website.
Now go into Google Analytics and create a filter. On the overview page go to 'filter manager'. Then click Add filter. Give the filter a name that it is going to filter out certain traffic. Set the filter type to 'custom filter', set this to exclude, Set the filter field to 'user defined' and set the filter pattern to the cookie string that you set in your code above (in my example I set this to exclude_browser_kevsapps). You can set case sensitive to no. The filter is a regular expression, but you do not need to put asterixes in front or at the end, because 'exclude_browser_kevsapps' will match the name if it is something like '1.exclude_browser_kevsapps' or ends with some additional text - I see that when you set the cookie in FireFox it adds this text to the beginning of the cookie name/value. Then select the websites (that you have in your Analytics account) that you want this filter to apply to. I suggest you set up a cookie specific to each of your websites, that way you have granularity to exclude browsers from one site, but not from the others if you so desire. Save changes and you are done.
Now for all the browsers you wish to test your website on, and exclude that traffic / your visits from Google Analytics, run the above page which sets the exclusion cookie.
