In order to track subdomains within the same profile as the primary domain, you will need to add an extra line in every pages with the tracking code.
Assuming your primary domain is “.your-site.com”
Following is the line you will need to add:

pageTracker._setDomainName(“.your-site.com”);
For example, it will look like this…


<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._setDomainName(".your-site.com");

pageTracker._initData();

pageTracker._trackPageview();

</script>

As a result, Google Analytics will throw the following results for each of these URLs.

  • www.your-site.com/default.html –> /default.html
  • shop.your-site.com/info.html –> /info.html

If you want to distinguish between your subdomains, you’ll need to create an “Advanced Filter” for your profile.

Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: /$A1$B1

Now, the results for the above examples will look like:

  • www.your-site.com/default.html –> www.your-site.com/default.html
  • shop.your-site.com/info.html –> shop.your-site.com/info.html

Related Articles:
Google Analytics – Linking Across Different Domains
Analytics Tracking and Reporting Online and Offline Campaigns
Overview of Implementing Google Analytics Tracking Codes

Tagged with →  
  • Daniel Kowalsky

    thank you.