Cross Domain Tracking – What It Is and How to Fix it

Cross Domain Tracking – What It Is and How to Fix it

One of the most common tagging problem comes from cross domain tracking. In this post I explain why cross-domain tracking can be a problem, and what your options are to fix it.

What is cross-domain tracking?

Cross-domain tracking happens when a visitor to your site is taken to another domain or sub-domain, and you are interested in viewing that activity as one big session rather than multiple small ones. For example, let’s say you have a blog ( and a sales page ( The main purpose of your blog is to get organic and social media traffic. In your sidebar, there is a link to your sales page. A typical visit goes like this:

  1. John types on Google, “how to do this amazing stuff.”
  2. The first entry in the Google search result is a link to an article on; John clicks on that link.
  3. John is taken to, where he sees the sidebar banner “Buy the new How-to Do This Amazing Stuff in Just 10 Seconds!”
  4. John clicks on the banner and is taken to
  5. John happily purchases your e-book for only 20 payments of $99 each.

The result? For, you see one visit with the traffic source = Organic/Google and Keywords = “how to do this amazing stuff.” For, traffic source = Referral/, Keyword = none.  This collection of information doesn’t provide the critical information you need as a business owner: which traffic sources and keywords bring you money. The three most common situations where cross-domain tracking is needed involve:

  1. Using separate domains for your blog and your sales page/squeeze page.
  2. Using the default thank-you message hosted by your auto-responder.
  3. Using a default third-party shopping-cart configuration without using a thank-you page hosted by your website, or adding your Google Tracking code the the shopping cart pages).

What is the source of the problem caused by cross-domain tracking?

The problem with cross-domain tracking arises from the fact that Google Analytics uses first-party cookies.

Sorry, Cookie Monster—I’m not talking about THOSE cookies!

Cookies are small text documents used to store information about your current and past sessions on a website. All cookies are named using the domain (or sub-domain) name of the site that created them. A first-party cookie is a cookie created by the website itself. If you check your browser settings, you should have a cookie named that was created by this site. When a new session is started on a site, Google Analytics checks to see if a cookie matching the domain (or sub-domain) exists. If it does,  Google uses the information in the cookie to track the visit. If the cookie doesn’t exist, Google creates one, sets the visit as the first one, and records all the information it has available (including traffic source, browser type, location, etc). Since the cookie’s information can’t be shared—unless of course you used the cross-domain tracking code—the data collected in one domain is not available to the next one.

One more example: My sad story

The day I start selling my e-book, I was so excited that I made the following error:

My sales pages


Traffic source : Organic /Google

Keyword : simple analytics

Track page view hell YES!

My shopping cart


Traffic source : NA

Keyword : NA

Track page view NO!

Purchase confirmation


Traffic source direct

Keyword unknow

Track page view YES!

While my purchase confirmation page was tagged with my Google Analytics tracking ID, the cookie created by e-junkie couldn’t access the traffic source information stored in my sales-page cookie ( The result?  My sales funnel looked like this: funnel_before

My reaction ? I started crying, of course!  After drying my tears, I checked my traffic source report and saw this: Traffic_source_before

I started crying again. Not good. Fortunately, I quickly realized what the problem was and fixed it. Now, my funnels looks like this: funnel_after

And my traffic source report looks like this: traffic_source_after

How can you track multiple domains or sub-domains?

Solution 1: The best way to solve a problem is to avoid it!

If you can avoid cross-domain tracking by hosting all your web pages under the same domain, then do it. That’s not always possible, but you should at least try to host your squeeze page/sales page under the same domain as the thank-you page or receipt page. Whenever you have the option to host your own thank-you page, do it! It will look more personal and you will be sure that your Google Analytics tracking code is there. In this case, the cross-domain tracking code is not required.

Tracking PayPal

The basic PayPal shopping cart doesn’t let you add your own Google Analytics tracking code. In this case, you need to redirect buyers to a thank-you page located under the same domain as your sales page. 

NOTE: Some people claim that you need to add the parameter ?utm_nooverride=1 to avoid overwriting the traffic source to PayPal instead of the real traffic source. In my last implementation, I didn’t use the parameter, and the traffic source was not changed to PayPal, so I don’t think this parameter is required.

If you structure your funnel in this way, so that it goes your sales pages -> PayPal -> your hosted thank-you page, you don’t need cross-domain tracking at all! Your code on both your sales page and thank-you page will look like this:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);

(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);


Solution 2: Use a cross-domain tracking code.

Sometimes you can’t host your blog, sales pages, and thank-you page under the same domain or sub-domain.  In this case, you will have to use cross-domain tracking to pass the cookie information from one site to the other using either the link() method or the linkByPost() method and a cross-domain tracking code. If you feel overwhelmed, don’t worry—the Yoast plugin can do all this for you. You can also refer to the Google Analytics documentation for help.

But this is important: To make it work, you have to use the SAME Google Analytics ID on every single domain/sub-domain you want to track.  If you fail to do this, it won’t work.

Case 1: Tracking a domain and subdomain

This one is the easiest. Let’s say you have your main website at and your shopping cart at The only thing you need to do is add  _gaq.push([‘_setDomainName’, ‘’]);  to your tracking code. Then use the following tracking code on both and

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', '']);

By using the function _setDomainName, you are telling Google Analytics to use the same cookie for both domain and sub-domain. Since both sites will then be reading the same cookie, there is no need to send cookie information using the link() method.

Case 2: Tracking two top domains

If your blog is at and your shopping cart or squeeze page is at, you will have to do two things to ensure tracking is done properly:

1. Change your Google Analytics scripts for to this:

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

And for to this:

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

Please note that I am using the same tracking id on both domains (UA-12345-1), that I am using the _setDomainName in case we also need to track subdomains (e.g.,, and that I am using _setAllowLinker. This function tells Google Analytics to use the cookie information stored in the URL parameter when the link() or linkByPost() is used.

2. Change ALL your links pointing both ways between your top domains with link() or linkByPost(). If you have a link from to your link should look like this:

<a href=""> Buy My Stuff</a>

You will have to change it to look like this:

<a href=”” onclick=”_gaq.push([‘_link’, ‘’]); return false;”> Buy My Stuff</a>

Once all this code is in place, the link to your should look like this in the browser :|utmccn=ebook-pre-sales|utmcmd=email&__utmv=101492227.|1=Member=Subscriber=1^2=JD=20130614=1^5=VWO-1=Control=1&__utmk=107434882

If you don’t see such a long ugly link, it is not working! All the parameters are in the cookie information stored by The setAllowLinker() function will tell Google Analytics to use those parameters to build the cookie instead of creating a new one from scratch.

Tagging each link manually—Are you loco?

A few years ago, you would have had to code each link manually.  Thanks to the Yoast Google Analytics plugin, this complicated job can now be done in about 10 minutes. See this video to learn how:

Oh! Did I mention that you should always host your own thank-you page under the same domain as your squeeze/sales page?

I know, this is complicated—but remember the real power is in the traffic source information, and without cross-domain tracking this information is lost. Leave your questions in the comment, if you have any.

Good luck!

The following two tabs change content below.

Marcos D'Urbano

Owner at Simple Analytics
During the past 10 years doing analytics and completing an MSc in Business Intelligence, I realized that very simple techniques can have a huge impact on our results and your bottom line. I created Simple Analytics because I do love analytics and firmly believe that complex things can be explained in a simple way. I teach and coach busy online entrepreneurs on how to use analytics to keep their business on track.