Google Analytics and sub-domain tracking

I am always championing Google Analytics as my analytical package of choice, not least because it’s free, but because I feel the functionality you get out of it, as a free package, is second to none when compared to the rest of the free/nearly free products out there. Out of the box, GA works with minimal setup or configuration, and works really bloody well.

Tracking sub-domains with Google Analytics also works, with the minimal of configuration, by simply amending your GA code (this is the most up to date version, just by the way):

_gaq.push([‘_setAccount’, ‘UA-XXXXXXX-1’]);

To read:

_gaq.push([‘_setAccount’, ‘UA-XXXXXXX-1’]);
_gaq.push([‘_setDomainName’, ‘’]);

Simple enough? Well, here is a a nice tidbit of information, if you have two pages on your primary and sub-domains, that share the same page name (i.e. index.html), then Google Analytics will combine the statistics for these two pages artificially inflating the statistics for index.html on the primary domain. As my good friend Rob put it: “I wonder who decided that this was a sensible default?” Sensible default indeed!

More endless searching led me to information on setting up a filter, which will supposedly split your data and track traffic on both sub-domains and the primary domain:
Google Analytics filter for sub-domains

Unfortunately, this didn’t work out too well either in my tests:
sub-domain tracking really doesn't work

So, calling on the Twitterverse, David Whitehouse from Bronco volunteered to help out and see if we could get this fixed, and came across the following filter configuration from Brian Clifton’s book:
Google Analytics subdomain tracking filter

This has now been set up, and I’m running a few more tests on some new pages and will report on results as soon as they’re in…


So it’s the morning after the afternoon before, and I can’t say the results are overly brilliant, especially when I spot the following duplication in my analytics overview:
Statistics duplicated in Google Analytics
Furthermore, the subdomain I have been testing is being treated like a subdirectory in the reporting:
Subdirectories and subdomains crossed over in Google Analytics
So when you hover over the “Visit this page” link in GA, you get the following in your status bar:

Not what I would call perfect, by any means.