Need to track multiple sub domains on one domain? Don’t fear the ‘profiles’ and ‘filters’ in Google Analytics, they’re very useful and actually fairly simple.
This tutorial assumes that Google Analytics is already installed on your website. If you operate a CMS, the following plugins are suggested:
Google Analyticator (WordPress)
Google Analytics (Drupal)
Google Analytics Tracking Module (Joomla)
So here is the scenario:
You want to track all of the sub domains individually to stop Google treating them as though they are all the root site. And, you would like to be able to track one or more of the sub domains individually.
Example domains:
www.domain.com
subdomain1.domain.com
subdomain2.domain.com
subdomain3.domain.com
Just follow these 3 easy steps:
1. Adjust tracking code:
First you need to add the following tracking code to all pages of your subdomains and main domains.
_gaq.push(['_setDomainName', '.domain.com']);
Make sure you include the ‘.’ before the domain (google seems to have made a booboo with this in some instructions)
tracking subdomains google analytics code snippet
NOTE: Be careful with the above. TrackPageview should only show once on the same page.
2. Set up 3 (or more) custom profile, each with a filter.
Old Analytics click here.
New Analytics: click the orange cog in the top right > Click ‘New Profile’
Note: before you start the next step, please note that you should not remove the existing profile. Retain it and rename it to ‘default’, or ‘all traffic’. DO NOT DELETE it!!!
1 to track the overall traffic.
tracking all subdomains google analytics filter configuration
2 to track subdomain1

track a single subdomain google analytics filter configuration only one
3 to track subdomain2

track a single subdomain google analytics filter configuration only one
3. Well, I lied. There is no step 3. Maybe set up some reporting if you need to…
Any questions on the above .. please ask away …
Note: Other solutions also exist for tracking between top-level domains and other Google Analytics sub domains tracking scenarios.



2 Comments
Hi there,
I don’t use the WWWin my website, how can I do it?
my case is like:
http://website.com
http://apps.website.com
http://games.website.com
thx
Hi sorry for the slow reply. I think I can help!
There are a number of methods for adding or removing the ‘www’ sub-domain.
If you are not a web hosting wiz-kid, the best method is to ensure the ‘web host control panel’ you choose adds the www automatically – one such control panel is ‘cPanel’ – cPanel is provided by many hosting providers like GoDaddy etc. Hope this helps. KJ