Tracking Multiple Domains with Google Analytics

Tracking multiple domains with Google Analytics can be challenging, you have to know that what you’re reporting, trending and analyzing is based on accurate data.  Otherwise, you will lack proper source that attributes towards your sales and goal conversions. Unless you have a master rollup account to report all of the data from the various sites, it’s very difficult to get accurate data.

In this post, I’m going to focus on explaining how to track multiple domains and help you make sure that you’re reporting accurate source attribution.  Whenever you have multiple domains, it’s easy for the data to get lost and you end up with a lot of referring traffic back to one of your websites and this doesn’t help if you’re a marketer.

Before we get into this in more depth, let’s discuss the basics about cross-domain tracking.  Google’s ga.js javascript looks for the existence of the first party cookie that’s on your computer.  If it doesn’t find a cookie, then it views that visitor as unique, someone who’s never been to your site.  First party cookies don’t transfer between domain names for security reasons and they have to be sent over to a 3rd party domain using GA paramaters in the link (or using an iframe).


Let’s pretend (Account A) sells children clothing and (Account B) sells adult clothing, in this case I made the illustration show 2 pages per site.  What you would want to do is setup 3rd Google Analytics accounts tracking full eCommerce transactions under one master profile. Let’s call the 3rd account (Account C), Clothing Holdings, which would collect all the data. Make sure the master profile (Account C) has no filters, this will help you have a baseline to refer to if you make any mistakes.

Next, you have to make your sure all your Google Analytics and Adwords accounts are linked up, you’ve opted into data sharing in your Analytics account and you’ve enabled auto-tagging in your Adwords account.

This is what you should be left with based on the illustration and scenario:

  • 2 websites –,
  • Reports (Master Profile) – Landing pages or websites report to this account (UA-XXXXXXXXX-C)


I’m going to break it down further, a vistor finds you through the children’s clothing site,, and then clicks on a link within your web site to the adult clothing store,  If you use Google Analytics on each web site independently, you won’t be able to know which landing page contributed to a sale or goal completion on the other site.  You won’t be able to know the duration of the visit starting from the other website leading up to sale, whether it was an organic or paid search term and even the keyword.  The only information that would show up in Google Analytics would be that the visitor was a referrer from your other web site and the referrer would be the page on your other site that had the link.

<script type="text/javascript">// <![CDATA[
  	var _gaq = _gaq || []; 	_gaq.push(['_setAccount', 'UA-XXXXXXXXX-A']); // A or B depending on site 	_gaq.push(['_setAllowLinker', true]); 	_gaq.push(['_trackPageview']); 	_gaq.push(['t2._setAccount', 'UA-XXXXXXXXX-C']); 	_gaq.push(['t2._setAllowLinker', true]); 	_gaq.push(['t2._trackPageview']);   (function() {     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })();
// ]]></script>

Let’s deconstruct it, starting with ‘_setAccount’ and by now I am hoping you know what that means.  The ‘_setDomainName’ is set to none because it turns off a unique hash feature which only allows it to be stored with that domain which by default is otherwise set to ‘document.domain’ – you do not need to use this attribute if you are linking between subdomains, for example, and  If you are using 2 domains as in the scenario, use it on the respective domain and not the Master Account.  The ‘_setAllowHash’ is deprecated and no longer needed to cross domains, that’s why you might see it in other older examples similar to this post.

To ensure that user information gets carried from to we would need to pass ‘_link’ (for links):

<a onclick="_gaq.push(['_link', '']); return false;" href="">Adult Clothing</a>

If we were passing a form from to, the tag would need to have the code example below.  A common scenario for this would be an online store where the first domain would hold the actual store and another domain would hold the check out page which leads to a sale, similar to Paypal or Google Checkout. When the customer goes from web site to checkout you would use the POST method to push the visitor’s info to the next domain. The example below references this scenario:

<form method="post">

When the visitor finally makes it to the confirmation page, the only main difference would be that you would add the ‘_SetDomainName’ and ‘_setAllowLinker’ for each respective account, Account C in this case being the constant.

<script type="text/javascript">// <![CDATA[
  	var _gaq = _gaq || []; 	_gaq.push(['_setAccount', 'UA-XXXXX-A']); 	_gaq.push(['_setAllowLinker', true]); 	_gaq.push(['_setDomainName', 'none']); 	_gaq.push(['_trackPageview']); 	_gaq.push(['t2._setAccount', 'UA-XXXXXXXXX-C']); 	_gaq.push(['t2._setAllowLinker', true]); 	_gaq.push(['t2._setDomainName', 'none']); 	_gaq.push(['t2._trackPageview']); 	_gaq.push(['_addTrans','1234','','20.00','3.00','5.00','Miami','Florida','USA']); 	_gaq.push(['_addItem','1234','DD44','Adult T-Shirt','Green','20.00','1']); 	_gaq.push(['_trackTrans']);   (function() {     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })();
// ]]></script>

There is one final step. You have to create a custom filter or the referral data that carries over will not show the actual domain, so under your Admin settings, you can add a filter to show the domain in the page reports as follows:

  1. In the Profile Settings page, click the Add Filter link.
  2. Choose Add New Filter and provide the filter a name.
  3. Choose Custom Filter and select Advanced on the Filter type settings.
  4. Under Advanced settings:
    1. FieldA should be set to Hostname
    2. FieldB should be set to Request URI
  5. Set the values for both Field A and Field B to (.*), which is an expression that captures all characters.
  6. Set the Output To –> Constructor option to Request URI and provide $A1$B1 as the value for that choice.

Your reports will now show:

In the earlier example, when I described linking from to, portion of your URL will be included at the beginning of your page URL in the Master Profile on Account C (UA-XXXXXXXXX-C).

As you can see there are a lot of moving parts to Google Analytics. Before you try to build an advanced scenario as one described, remember we’re to here to help.  Feel free to post any questions or suggestions you have in the comments below.

Adam Boalt
About the Author Adam Boalt

Serial Entrepreneur and Emerging Technologies Evangelist. Interactive Strategy, User Experience, Search Marketing, Search Optimization and Social Media enthusiast.
Read All Posts By Adam Boalt

Short Film “Drained” Wins Its First Film Festival Award Ignite Miami – Hacking Innovation