Reducing Analytics Inaccuracy as a Result of Website Development
If you’re anything like me and work on a multitude of various websites you’ll have different versions of sites all functioning at the same time; maybe a copy running on your localhost for development, a staging version and the live production site visible to the public.
With an analytics package running on these sites, continuous page hits through testing will most definitely skew the statistics data and give false feedback when analytics reports are generated. This can be especially critical when a client sees 1,000 pageviews a day on their site when, little do they know 990 of them are you developing a new section.
There are two methods I use to prevent this inaccuracy:
Method 1 – IP Address Filtering
Most analytics packages provide the ability to exclude hits from predefined IP addresses. Google Analytics for example has what they call a ‘Filter Manager’. In here we can choose to exclude our localhost IP address (127.0.0.1) and our public IP address which can be obtained from a site such as www.whatismyip.com.
Cons: This will only work if you have a static IP address. Also, if you develop from various locations or have multiple developers working on a site you will have to ensure each of these unique IP addresses are included in the filter.
Method 2 – Specifying Domain
The other alternative is to only show the analytics code on the live domain. A simple example of this can be seen below where, by using PHP, I only show the Google Analytics tracking code on the live domain:
In above example I am only checking against the one domain variant. In order for this to be more efficient you would also want to check against other ways people may access the same site; maybe via IP address or without the ‘www.’.
Cons: As this tracks all visits to the live site it would still count your/the developer’s testing and general browsing hits.
In my opinion I would say the first method is generally preferred, especially if it is only you and/or your team developing a website. As with everything however you should judge each case on it’s merits and find a method that suits you best to reduce inconsistencies in your anaytics data.