I saw a question on the Yahoo Message Board about Tracking Sub domains using Google Analytics – and yes, it can be done well, provided you take a few steps – I’m writing this post to make sure I remember them too – I write as much to keep track of information I come up with and make sure I have it when needed.
The question came from David Culbertson over at LightBulb Interactive and the answer I left included a reference to this page on AnalyticsTalk - Tracking Sub Domains with Google Analytics
This is a issue that come up often – a lot of sites use sub domains – http://www.Monster.com (where I’m currently working) uses a lot of sub domains, btw. We even have some GA stuff we’re playing with and this very issue has come up.
“…What if you want to track one group of sub domains in one profile and a different group of sub domains in another profile? Or what if you want to create new profiles for a different groups of sub domains in the future?”
Justin, who I’ve met a couple of times, over at EpikOne, is one of the foremost Google Analytics experts out there – EpikOne probably has done more variety of GA Installs and Support than most Google Analytics Channel Partners. Here’s what he has to say about the Sub domain issue:
1. Create Profile for The Primary Domain
The first step is to create a master profile. All other profiles for the website, including profiles for the various sub domains, will be based on this profile. When you enter the domain for the website use the primary website domain. In the example below, I’m using http://www.sitedomain.com as the website domain.
After creating the profile GA will display the tracking code for the site. Before you add it to your pages it must be modified. You need to force GA to use the primary website domain for the cookie domain. This modification will let you track each unique visitor across all sub domains. This in turn let’s us collect all site data in a single profile and do ‘roll up’ reporting.
Old urchin.js tracking code:
New ga.js tracking code:
Note: Use the new tracking code if you can as it enables Site Search tracking and Rich Media Tracking along with outbound links.
2. Create Profiles for All Sub Domains
Once you have created the master profile you can start creating profiles for each of the sub domains. Remember, each sub domain profile is based on the master profile, that we created in step 1. Here’s how to set up the new profile:
Now that you’ve created the profile, make sure you add the tracking code to the pages on the sub domain. The tracking code for the sub domain is the same as the tracking code that goes on the primary domain (it’s the code from step 1).
3. Add Filters to Sub Domain Profiles
The next step is to add a filter to the sub domain profile so it only contains data for the appropriate sub domain. This is done using an include filter based on the hostname. Once this filter is in place you’ll have the master profile which will contain data for all sub domains, and this profile that will contain data for a specific sub domain.
To create additional profiles for other domains just repeat steps 2 and 3. Obviously the settings for the filter used in step 3 will depend on the sub domain that you want to include in the profile.
Creating Additional Profiles
Let’s say you need to create a profile for two sub domains: 1.website.com and 2.website.com. This can easily be done because the same tracking code is on both sites. All you need to do is add an include filter with the following settings:
While Google’s documentation describes a good way to track sub domains, I think this approach is better due to it’s flexibility. Plus, because the same tracking code is used all all sub domains you don’t need to worry about placing the wrong tracking code on a sub domain.
Good point – you want to think about flexibility and long term use at the very onset of installing anything.