Filtering users with a cookie in Google Analytics

If you wish to filter out all internal traffic to a site (e.g. all the employees in a company to the company website), then you can create a custom cookie which will be placed on their computer when they view a specific page on the site. You can then set this cookie to be filtered in Google Analytics to ensure the visits from employee’s computers are not counted towards the overall site traffic.

This can be useful if the company website is set as the default homepage in the browsers of the employee’s computers, but most employees simply ‘bounce’ off the site in order to view other sites on the web. This behaviour will give a large number of direct visits, and also a very high bounce rate, and thus skew the site statistics.

To use this simple method to filter out internal traffic, simply create a new page on the site, which is not linked to from any other pages (in order to stop it being indexed by search engines, or found by external visitors). Then add the code below to the body tag:

<body onLoad=”javascript:pageTracker._setVar(’test_value’);”>

Please note that this code is in addition to the Google Analytics tracking code that you have on every page of your website. “test_value” is a custom field.

In order to set the cookie, visit your newly created page from all computers that you would like to exclude from your reports.

Different browsers on the same machine will need to visit the page separately.

Create an Exclude filter to remove data from visitors with this cookie. Go to the Profile Settings of your site in Google Analytics and add a new filter with the following settings:
 
Filter Type: Custom filter > Exclude
Filter Field: User-Defined
Filter Pattern: test_value
Case-sensitive: No

Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • Sphinn
  • StumbleUpon
  • YahooMyWeb

Leave a Reply

SEO and SEM Tutorials, Training & Consultancy