Normally when you are setting up Google Analytics (or any other web analytics program for that matter), you want to set it up so that it doesn’t count traffic from visitors using the site on behalf of the site owner. This may include employees of the company that owns the site, web developers or online marketers contracted by the site owner, etc.
Usually this is done quite simply by using a filter to exclude the IP addresses of the visitors in question. There is a twist, in that you need to use regular expressions (which in this case means using the ‘\’ in front of the ‘.’s in the IP addresses so they are not treated as wildcards), but the process is pretty well explained in the Google Analytics help topic called ‘How do I exclude my internal traffic from reports?’. Google even provides an IP range tool to help with getting the right regular expression to cover a range of IP addresses.
Of course, this process assumes that the visitors that you want to screen out are operating from fixed IP addresses. For people working from home, or even small businesses, this may be not be the case, as they may using IP addresses dynamically provided by their ISP. The way to address this is through use of a cookie that can be set upon visiting a page dedicated for this purpose and then filtering out visitors based on the presence of the cookie.
This solution is addressed at the bottom of Google’s ‘How do I exclude my internal traffic…’ page, but I thought it was worth elaborating on. The information below is derived from the Google page but with some enlightening information from Brian Clifton’s excellent book ‘Advanced Web Metrics with Google Analytics.’
There are two stages to the process:
- Set up a dedicated page that will set a cookie on the visitor’s browser using Google Analytics code.
- Set up an exclude filter in Google Analytics that will cause GA to ignore traffic from visitors carrying the cookie
Step 1: Set a Cookie
- Create a new blank html page.
- Insert the usual GA tracking code for the site on the page between the <body></body> tags.
- Save the page on your server with a name like ‘ga-exclude.html’.
This _setVar() value is then stored in the _utmv cookie when a visitor visits the page.
Step 2. Add an Exclude Filter in GA
Analytics>Profile Settings>Edit Filter
Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: exclude_visitor (must match the value of _setVar)
Case Sensitive: No
Brian says in ‘Advanced Web Metrics’ that the “value of setVar() is stored in the Google Analytics field labeled User Defined.” (p. 70) I take this to mean that the field labeled User Defined references the _utmv cookie (which holds the value of _setVar() ), but in any case, this explains the use of ‘User Defined’ in the filter field.
All that’s left to do is to point the visitors that you don’t want to track to the cookie page (‘www.yoursite.com/ga-exclude.html’). Once the cookie is set on their browser, it will be there for 24 months, during which time their visits to the site will not show up in Google Analytics. Voila!
To streamline the process, I have created a basic html template file that can be used as the file that sets the cookie. To use this file:
- Download it and open it in a web editor/text editor.
- Insert the site GA tracking code above the </body> tag.
- If necessary, review the instructions in the file.
- Upload to the server and set up the exclude filter in GA.
Filed under: Google Analytics |