There are two ways in approaching tracking the website across multiple domains using Google Analytics. First, note the difference between “multiple subdomains” and “multiple root domains”.

Example of Multiple Subdomains
www.example_site.com
and
blog.example_site.com

Example of Multiple Root Domains (two different domains)
www.example_site.com
and
www.example_store.com

How to track the subdomains of the website in one profile

1) You can track subdomains within the same profile as the domain by addin an extra line into your tracking code (in bold).

NEW CODE (ga.js)
var pageTracker = _gat._getTracker(“UA-xxxxxx-x”);
-> pageTracker._setDomainName(“example_site.com”);
pageTracker._initData();

OLD CODE (urchin.js)
_uacct = “UA-xxxx-x”
-> _udn=”example_site.com”;
urchinTracker();

Keep in mind that this will allow you to track subdomains within one profile, but you may not be able to distinguish between pages coming from the main domain versus the subdomain.

2) If you need to distinguish between the subdomains, advanced filter for your profile needs to be set.

For Example:

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

How to track the site across multiple domains

1) You need to add the following lines (in bold) to your Google Analytics tracking code.

NEW CODE (ga.js)
var pageTracker = _gat._getTracker(“UA-12345-1″);
-> pageTracker._setDomainName(“none”);
-> pageTracker._setAllowLinker(true);
pageTracker._initData();

OLD CODE (urchin.js)
_uacct=”UA-xxxx-x”
-> _udn=”none”
-> _ulink=1;
urchinTracker();

2) Next, you will need to add the _link function to any links between the domains.

Example for new ga.js :
.. href=”http://www.example_store.com”> onclick=”pageTracker._link(this.href); return false;”…

Example old urchin.js :
.. href=”http://www.example_store.com”> onclick=”javascript:__utmLinker(this.href); return false;”…

3) If you send information between domains using forms, you’ll need to apply the following.

Example for new ga.js :
.. action=”http://newdomain.com/form.cgi” onSubmit=”javascript:pageTracker._linkByPost(this)”

Example old urchin.js :
.. action=”http://newdomain.com/form.cgi” onSubmit=”javascript:__utmLinkPost(this)”

4) The data in the report will only include the request URI and not the domain name. If you want to see the domain names, then you 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

Tagged with: