How to Set Up Cross Domain Tracking For Multiple Domains in Google Analytics

Sometime you find some websites use third party check out on other websites or domains. If you haven’t set the cross domain tracking in Google analytics then you can’t track the traffic, sales or what is happening on other domains. Instead of complete information you can see only self-referrers in the visit reports at Google Analytics. Let first understand why this happen and how we can track the cross domain traffic for multiple domains.

When visitors moves form one domain to other domain a brand new session will start in Google analytics. Google analytics use the first part cookies and these cookies are attached on visitors browser. As visitors visit the website, or visit the different pages of website or do all other things in website the ga.js java script search for the existence of that first party cookie. If Google analytics couldn’t find that cookie then it will count visitor as new visitor on website. Google analytcis are best available cookies but for privacy and security reason they don’t transfer the data between different domains. Thus first party cookie is linked with one set domain so it will be not be accessible by other domain.

google-analytics-tracking

This first party cookies can create a big problem in tracking the traffic from other domains. Suppose, if visitors come to your website from organic search and then went to other website for purchase, in this case you will lose all the data about how user arrived and what he did. So in order to track the visitors from one website to other website, you need to make some modification in both websites tracking codes. Lets take examples of two websites, www.mywebsite.com and www.thirdpartycheckout.com.

Set Up Tracking

One thing which you need to take care when you set up tracking on multiple domains together in same report, you should have same tracking-code snippet on the pages on each domain, you need to change value for _setDomainName differently for each domain.

For example, if we are tracking www.mywebsite.com and www.thirdpartycheckout.com and you want to consolidate information under mywebsite.com, then you should set the tracking code as follows for each domain:

mywebsite.com
<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-99999999-1']);
_gaq.push(['_setDomainName', 'mywebsite.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’;
ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ :
‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(ga, s);
})();

</script>

thirdpartycheckout.com

<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-99999999-1']);
_gaq.push(['_setDomainName', 'thirdpartycheckout.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’;
ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ :
‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(ga, s);
})();

</script>

After doing this we need to set up cross links

Set up cross links

If you’re setting up traffic from www.mywebsite.com to www.thirdpartycheckout.com and traffic moves from mywebsite.com to thirdpartycheckout.com, and your current links have a form like:

<a href=”https://www.thirdpartycheckout.com/?login=parameters”>View Cart<</a>

change the form to:

<a href=”https://www.thirdpartycheckout.com/?login=parameters” onclick=”_gaq.push(['_link',
'https://www.thirdpartycheckout.com/?login=parameters']); return false;”>View Cart</a>

If traffic can also move from thirdpartycheckout.com to mywebsite.com, and your current links have a form like:

<a href=”https://www.mywebsite.com/”>Continue Shopping</a>

change the form to:

<a href=”https://www.mywebsite.com/” onclick=”_gaq.push(['_link',
'https://www.mywebsite.com/']); return false;”>Continue Shopping</a>

Set Up Forms

If you send information between domains using forms, then you need to use the _linkByPost() method.

<form name=”f” method=”post” onsubmit=”_gaq.push(['_linkByPost', this]);”>

How to See Different Domain Names
By default, Google analytics show the path and name of page and not name of domain. So it would be difficult to track which page belong to which domain. So in order to check the domain name in your report you need to create advanced filter for your profile with following setting:

Filter Type: Custom filter > Advanced

Field A: Hostname Extract A : (.*)

Field B: Request URI

Extract: (.*)

Output To: Request URI

Constructor: $A1$B1

If you’re using advanced filter it would be better if you create a few profile or duplicate profile for your website.

Article by

Dinesh Thakur is editor of Click Conversion Blog. Dinesh write about Digital Marketing, SEM , SEO and Web Analytics. You can follow him at Google+

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>