Tracking multiple domains through a single Google Analytics account

Tracking multiple domains through a single Google Analytics account

  •  
  •  
  •  
  •   
  •  

Data accuracy is crucial in gaging a website’s performance through Analytics statistics. If you are a webmaster who has multiple domains/subdomains and want to track the performance of all them, you can do so through a single Google Analytics account. Here’s how to do it:

Let’s assume you have three domains – www.a.com, www.b.com and www.c.com
and want to track the performances of all these through a single Analytics account.

Step 1: Create separate Google Analytics accounts for the domains. For instance, let’s presume the different accounts are UA-AAAAAAA-1, UA-BBBBBBB-1 and UA-CCCCCCC-1

Step 2: Now, create a single overall account which can show the details of all the three domains. Let’s assume this is example account id for the overall tracking account – UA-ddddddd-1.

Use the below script and create Page Tracker variable for UA-AAAAAAA-1 account (with all its subdomains) and also create the overall tracker variable as UA-ddddddd-1 for the overall account.

<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”>
try {
var pageTracker = _gat._getTracker(“UA-AAAAAAAA-1”);
pageTracker._setAllowHash(false);
pageTracker._setDomainName(“.a.com”);
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
var overallTraker = _gat._getTracker(“UA-ddddddd-1”);
overallTraker._setAllowHash(false);
overallTraker._setDomainName(“.a.com”);
overallTraker._setAllowLinker(true);
overallTraker._trackPageview();
}
catch(err) {}
</script>

Methods to be used from ga.js API

setDomainName: This method will set the cookie for the domain. Put “.a.com” as the argument to get the cookie details for all the subdomains of www.a.com

setAllowHash: The value here would be set as ‘True’ by default. However, to track multiple subdomains, set the value as ‘False’. Only when the code is set as ‘false’, you will be able to track all subdomain activity.

setAllowLinker: This method is for cross domain user tracking. By default it is set as ‘false’ to stop passing of any link query string through the cookie. However, to pass the link query string to the next page, set the value as ‘true’.

Note: Replace UA-AAAAAAAA-1 with the remaining two accounts (UA-BBBBBBBB-1 and UA-CCCCCCC-1). In the same way, replace .a.com with .b.com and .c.com for tracking subdomain details of www.b.com and www.c.com .

Step 3: Repeat Step 2 coding for the remaining two domains and track them too in the overall account.

Step 4: Set the filter conditions in the custom filter with the advanced options as given in the screenshot below:

create filter for multiple domain

You will get domain name or subdomain details together or separately in the Analytics report depending on how you set the Fields. If you set Hostname for both Field A and B, you will get the full content performance of Home.aspx only. Instead, if you set Request URI to Field B, you will get the subdomain details separately as in the following screenshot.

final result after filter

For further information on how to do multiple domain tracking through a single Analytics account, visit http://analytics.blogspot.com/2009/09/advanced-structure-your-account-with.html

, ,

Open chat
1
Hello
Can I help you?