Tuesday, September 29, 2009 | 11:58 AM
Labels: Advanced Topics
There are two distinct sections of this post:
- The Strategy (non-technical)
- The How (technical)
Before I go into details of the solution, and for simplification, let us assume we are dealing with a project that has the following requirements:
- A business with 3 domains (www.a.com, www.b.com, and www.c.com)
- 1 domain (a.com) links to a 3rd party shopping cart (www.mystore.com)
- 2 domains (a.com and b.com) have multiple sub-domains
- Track each domain and sub-domain separately (e.g. www.a.com, news.a.com, and blog.b.com)
- Track the rollup/overall traffic for all domains and sub-domains
- Track full e-commerce transactions
- Create a Google Analytics account for each domain (www.a.com, www.b.com, and www.c.com)
- Customize the tracking code to link the multiple sub-domains with their main domains
- Link the third party shopping cart with the main domain and install Google Analytics tracking code in all shopping pages
- Create a rollup Google Analytics account and add its code to all domains and sub-domains
The How:I will try to illustrate the technical implementation in 10 simple steps:
1- Create a unique Google Analytics account for each domain www.a.com, www.b.com, and www.c.com and then use the account number UA-AAAAAAAA-1 in the code in step 3 and use the accounts UA-BBBBBBBB-1 for www.b.com and UA-CCCCCCCC-1 for www.c.com in the code in step 8.
2- Create a Google Analytics account for the a rollup account that will oversee all domains and sub-domains (use the GA account number UA-XXXXXXXX-1 in the code used in step 3 and 8)
3- Add the following Google Analytics tracking code to the main site (www.a.com) and its sub-domains (blog.a.com, news.a.com, images.a.com, and media.a.com)
About the following code: We have a regular pageTracker object to track activity on each particular subdomain and a rollupTracker to track activity across all subdomains and the third party checkout site. (Click here to learn more about the customizations we made to the standard Google Analytics tracking code)
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
var pageTracker = _gat._getTracker("UA-AAAAAAAA-1");
var rollupTracker = _gat._getTracker("UA-XXXXXXXX-1");
4- Enable E-Commerce Reporting
Analytics Settings > Profile Settings > Edit Profile Information
5- Add the following code* to all shopping cart pages on the store site (www.mystore.com)
*Make sure to add this code to the top of the pages.
6- Add the e-commerce tracking code to the confirmation page after the GATC.
Read more about "How to track e-commerce transactions?"
7- Change the links to the store site (www.mystore.com) on the main site (www.a.com) to use _link as following:
If the current link looks like:
Change it to:
8- Repeat step number 3 for domains www.b.com and www.c.com after updating the Google Analytics account number UA-AAAAAAAA-1 and the setDomainName value.
- To view the entire code for www.b.com and its sub-domains (click here)
- To view the entire code for www.c.com (click here)
9- Create a profile for each sub-domain (only if needed)
In order to track a sub-domain (ex. blog.b.com) in its own profile, follow the following three steps:a- Create a filter that include only traffic from Hostname=blog.b.com
c- Apply the sub-domain filter to the new profile
10- As you might have noticed from the codes that we added so far to all pages, we added an extra Google Analytics account to track all pageviews across domains and sub-domains to one Google Analytics account. We call this account “rollup account”.
Since in the rollup account, we will track pages from different sites and many of these pages might share the same naming convention, I suggest that you create an advanced filter that adds the hostname to the page name to differentiate between pages with same URI.
Once you apply the filter, the upcoming data will appear as following:
If you have been with us so far, you are now ready to conduct your analysis based on clean and much more accurate data :)
- To review each domain by itself and for deep-dive analysis, use the domain profiles
- To get an overview and to see how the business is doing across all sites, use the “Rollup Account”