Monday, March 02, 2009

Google Analytics - Exclude visits from Dynamically Assigned IP address networks

Recently we ran into a problem where one of our clients manages his website from a connection with a dynamically assigned IP address. We therefore had the challenge of removing his traffic from the stats. We came up with two ways of achieving this goal. Both are good candidates so feel free to use whichever suits you best. Remember your statistics should be as accurate as possible to help determine how to proceed with website changes and marketing plans.

Solution 1 - Cookie Based


This solution involves creating a page and setting a cookie value which can then be filtered out in the profile settings. The benefits of this are that it is simple to set up and manage. You can use this page for anyone whos traffic you want to remove from your site, like external developers, QA/usability testers etc.

To set the cookie you need to create a new page on your domain with the following code:

body onLoad=”javascript:__utmSetVar(’remove_my_traffic’)”


Note that this code is in addition to the actual Google tracking code. I would call the page something non-guessable just to make sure nobody happens to go to this page by mistake.

The final step is to actually create the filter via your Google Analytics account. For this you will need to create an exclude filter to remove data from visitors with this cookie set. Follow the instructions at http://www.google.com/support/analytics/bin/answer.py?answer=27207&topic=2970 to create a filter with the following settings:

Next create an exclude filter in google analytics. See here for further instructions on how to create an exclude filter like the following:-

Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: remove_my_traffic
Case Sensitive: No

Then all you have to do is visit this page and your traffic will be filtered out on any profile you apply the filter to.

The downsides to this approach are that if you use multiple browsers you will need to visit the page you created to set the cookie in all of them. If you clear your cookies in any browser you will have to revisit this page to set the variable again. Also there is a slight chance a user can visit this page, but the more obscure you make the page name the harder it will be for a user to accidentally arrive at this page.

Solution 2 - Dyndns.org based

dyndns.org allows you to create a domain and assign it a static IP address, which you can then configure on your router. This then means any traffic going from the network behind your router will always have a static IP address for instance 114.23.23.23. You can then set up an exclude filter based on the following

Filter Type: Exclude all traffic from an IP address
IP address: 114\.23\.23\.23 (the one assigned to you by dyndns.org)

The benefits of this approach are it's fast and simple, it is “set and forget”, you don't need to worry about setting cookies every time you clear your browsers data or decide to use a different browser.

If you are a low traffic start up I would advocate both solutions. Solution 1 for any external testers or developers and Solution 2 for your internal network traffic.

No comments:

Post a Comment