

News Archive
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
Advanced: Structure Your Account With Roll Up Reporting And More
September 29, 2009, 11:58 am
There are two distinct sections of this post:
- The Strategy (non-technical)
- The How (technical)
The Strategy
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
Now on to the technical stuff. If you don't enjoy javascript and regular expressions, you may stop here and ask your webmaster or technical analyst to read further :-)
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)
<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 rollupTracker = _gat._getTracker("UA-XXXXXXXX-1");
rollupTracker._setAllowHash(false);
rollupTracker._setDomainName(".a.com");
rollupTracker._setAllowLinker(true);
rollupTracker._trackPageview();
}
catch(err) {}
</script>
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.
<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._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
var rollupTracker = _gat._getTracker("UA-XXXXXXXX-1");
rollupTracker._setDomainName("none");
rollupTracker._setAllowLinker(true);
rollupTracker._trackPageview();
}
catch(err) {}
</script>
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:
<a href="https://www.mystore.com">Buy Now</a>
Change it to:
<a href="https://www.mystore.com" onclick="pageTracker._link(this.href); return false;">Buy Now</a>
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
b- Create a profile and name it "Blog"
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”.
var rollupTracker = _gat._getTracker("UA-XXXXXXXX-1");
rollupTracker._trackPageview();
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”

Related Posts
Posted by Allaedin Ezzeidin, Analytics Specialist @ E-Nor, a Google Analytics Authorized Consultant








