Advanced: Structure Your Account With Roll Up Reporting And More
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)
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






25 comments:
Carson said...
Very helpful post! Will be implementing this strategy on our websites.
7:07 PM
Павел Романов said...
What is the difference between
rollupTracker and secondTracker?
3:48 AM
Mehdi from Brussels said...
var rollupTracker = _gat._getTracker("UA-XXXXXXXX-1");
rollupTracker._setAllowHash(false);
rollupTracker._setDomainName(".a.com");
rollupTracker._setAllowLinker(true);
rollupTracker._trackPageview();
}
setDomainName(.a.com); for the roll up account?
Are you sure?
7:23 AM
Rasmus said...
Great advanced stuff to dive into!
For analytics across multiple GA reports you can also use these tools that run on the GA API:
- Multi report analyzer for GA: http://www.youcalc.com/apps/1253630277450
- Real-time query builder for GA API: http://www.youcalc.com/apps/1249652239535
12:55 PM
Charudatta said...
This is a great post. Thanks a lot for sharing this.
However, is it possible to tweak the implementation in the following manner:
1) Have only only GA Account: say: www.x.com (a dummy domain name or can be any of the three domain names).
2) Use this id on each page, however on each site, set the domain name to "none" and each pageview on the site can be _trackPageview("/a/PAGENAME").
3) We will still have 3 profiles for each site, where the filter would be include only data from subdirectories "/a/", "/b/", "/c/".
4) We will still need to link the shopping cart, but we can do it in the similar fashion.
This way we eliminate the need for the extra profile and still track all the data.
Let me know what you think.
Thanks,
3:56 PM
droose said...
Sounds great and very useful for big clients with many websites!
But one question though: how about the cookies that are set?
First account A sets cookies (__utma, __utmb, __utmc, __utmz and/or __utmv), and then account X does the exact same thing...
Won't the cookies of account X overwrite the cookies sent by account A?
12:46 AM
Spanishgringo said...
I basically already have this setup for our sites. However, Google's own support was telling me that it is not a supported configuration. They need to send out a memo to get this understood by the fellow googlers
Here is the e-mail from Analytics Support:
Hello Michael,
Thank you for your email and I apologize for the inconvenience. However, I
would like to tell you that we don't recommend placing multiple tracking
codes on a website as this might lead to incorrect reporting of data.
Please note that this feature is not a supported implementation.
For additional questions, please visit the Analytics Help Center at
http://www.google.com/support/googleanalytics/?utm_id=tf. You can also
find helpful tips and information by visiting the Google Analytics Help
Forum at
http://www.google.com/support/forum/p/Google+Analytics?hl=en&utm_id=tr.
Sincerely,
[NAME DELETED TO PROTECT THE GUILTY]
Analytics Support
*************************
For the latest updates as well as some helpful tips on Google Analytics,
check out the Google Analytics blog at http://analytics.blogspot.com
*************************
7:26 AM
Allaedin Ezzedin said...
@Павел Романов: There is no difference. You can give your second tracker any name. (ex. var ILoveGA = _gat._getTracker("UA-XXXXXXXX-1");)
5:52 PM
Allaedin Ezzedin said...
@Mehdi from Brussels: Yes, I am sure :)
Remember in addition to tracking www.b.com and www.c.com in the Roll Up, we want to track www.a.com and its sub-domains
5:58 PM
Allaedin Ezzedin said...
@Charudatta: As I mentioned in the post "There are many ways to structure your Google Analytics profiles when you have multiple domains and subdomains. But in this post I will limit myself to the one that I like the most and I believe is the least confusing."
If you got the chance to try your approach, please share with us your findings. Thanks :)
6:10 PM
E-Nor said...
@droose: Both trackers use consistent settings so there is no threat to cookie integrity.
3:15 PM
Mehdi from Brussels said...
Actually, you wrote: "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."
You don't think that you should use "none" instead of ".a.com" for the roll up tracker? I interpret that as you wanted to use setDomainName(".a.com") on all domains (a, b, c), which would not be correct. On domains b ans c GA would interpret that as a third party cookie. What do you think?
9:56 AM
Jesse Littlewood said...
What about Event tracking reporting in the roll-up account? Can you show the domains that the events took place on?
1:26 PM
Jesse Littlewood said...
One other question: how about reporting? Is there an easy way to create a weekly generated report of unique visitors per each domain? So it would read:
www.a.com 500 visitors
www.b.com 300 visitors
Thanks!
8:20 AM
Allaedin Ezzedin said...
@Mehdi: I did not say add “setDomainName(".a.com") on all domains (a, b, c)”. Actually, I have provided the code that should go to each domain b.com and c.com (see step 8)
Thanks,
4:58 PM
Michael said...
Very helpful thanks! Using this approach would it be possible to track unique visitors across each subdomain?
5:08 PM
Allaedin Ezzedin said...
@Jesse: I did not test event tracking on cross domains, but it should work fine. If your account is already white listed for the "Second Dimension" cool feature, just go to the "Event Tracking" report and set the second dimension to "Hostname" and view the list of all domains.
5:23 PM
Christopher Schwede said...
What if I want to summarize three sites with different currencies each in a rollup account?
6:02 AM
David Wenzel said...
Great posts it is very helpful.. Could you tell me how many website we can add with one Google analytic account..
pitney bowes supplies
6:48 AM
Joanna said...
THANK YOU for this!
It is so timely. :)
12:42 AM
Leonardo said...
Hi,
is it really necessary to create differente accounts or is it sufficient the creation of different tracking codes into an unique account setting different domains?
Also in this second case GA generates different tracking codes (UA-XXXXXX-1, UA-XXXXXX-2, UA-XXXXXX-n). Using an unique account could preserve the 1-to-1 connection with a (potential) AdWords account...
8:45 AM
Allaedin Ezzedin said...
@Leonardo: You can go in that route if you like.. Your project requirements should decide which way you want to take.
Here are two scenarios of why I push for my approach:
- Sometimes you want to grant certain users admin access to one account and not to other accounts. Let's say you want Tom to have an admin access to b.com account and not to the a.com and c.com accounts (this is a very common scenario for businesses who use more than one marketing agency/web designer/consulting firm for their different sites)
- For a consulting firm like e-nor who creates 5-10 filtered profiles for each domain for deep analysis, it will be very messy to include all domains under one account.
2:16 PM
Allaedin Ezzedin said...
@Jesse Littlewood: Yes, you can :)
1- Login to the Rollup account.
2- Go to: Visitors > Network Location > Hostnames.
3- Click on: Email report button.
4- Add email, Subject, File Format, and Date Range/Schedule.
2:35 PM
See-ming Lee said...
Great post. Super helpful!!! Thanks!!!
Cheers,
SML
6:41 PM
phildamanstr said...
Your instructions state to create a new account for each domain you want to track via the rollup. Do you mean create a new profile? Because I cannot create a new GA account.
Also, what URL do I use when creating the Rollup account (or Profile)? Also, which option do I need to click: A Single Domain, One Domain with multiple subdomains, or Multiple top-level domains?
8:07 AM
Post a Comment