Track Subdomains in Google Analytics
With software as a service (SaaS) vendors like Compendium, you delegate a subdomain and host your blog on a different subdomain than your website. Commonly, this is accomplished with blog.domain.com and www.domain.com. Typically companies implement a totally separate account in Google Analytics to monitor the blog subdomain. It’s actually not necessary.
Google Analytics will allow you to monitor multiple subdomains within a single profile. To do this, you simply add a line of code to your current Google Analytics script:
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._setDomainName(".example.com");
pageTracker._trackPageview();
} catch(err) {}
</script>
You’re not done yet! If you simply do that, you run the issue of identical paths being measured under a single URl in Google. So – if you have index.php on your blog and www subdomains, they’ll both be measured as index.php. That’s not good. As a result, you have to do some fancy advanced filtering in the account!
Login to Google Analytics and click Edit on your Google profile. Scroll down the page where you can add a filter and add an advanced filter with the following settings:
Now your profile should distinguish the subdomain throughout all the Analytics Account.





