We normally track the traffic to our websites through Google Analytics. For this we have to just place the analytics code in the source code of the web-pages and thats done.
But what if the case is like we want to track the traffic of a domain and subdomain separately e.g We have a website abc.com and a subdomain on it xyz.abc.com. We want to analyse traffic for these two domains separately. In such a scenario Google Analytics requires adding a new line in the analytics source code of all the domain and subdomain pages.
The new code looks like this:
<script type=”text/javascript”>
var gaJsHost = ((”https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(”%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-xxxxxx-x”);
pageTracker._setDomainName(”example.com”);
pageTracker._initData();
pageTracker._trackPageview();
</script>
The line marked in bold needs to be added into the existing analytics code in all domain and sub-domain pages and refers to the primary domain. After adding this code on all the concerned pages, we can easily track the domain and sub-domain traffic through a single profile in Google Analytics. Here’s wishing you tons of traffic to your website!!




2 comments
Comments feed for this article
June 12, 2008 at 6:46 am
Surbhi Goyal
this is a really informative blog.. Keep it up… Keep updating this with the latest information on Google Analytics…
June 12, 2008 at 4:53 pm
pachi
thanks for tip