One of the biggest mistakes sites make is send visitors away to do the most important thing(s) you want them to do. For example, sending a visitor off your site to purchase something, fill out a form, apply for a job, reserve a hotel room, book a flight … You get the idea.
Why, you ask? Simple. When they leave, they take their data with them.
I identify this issue in way too many analytics audits, which is why I want to address it here.
A Tale of Two Options
When it comes to integrating data across multiple domains you have a couple options, but they’re a bit nuanced.
Option 1: Referral Exclusion List
I’ve already addressed how to rock Google Analytics’ Referral Exclusion List, and it’s an important read. At minimum, you should make sure your domain is on that list because it helps rid your account of self-referrals. You can list any other third-party or partner sites you want to include in a single session. Just keep in mind traffic from any domain or subdomain you list here will show up as direct, so you don’t want to just throw in all of your partner sites (something I’ve seen several times now in audits).
This is your best option if you either don’t need to know what the visitor is doing on the third-party site or you’re using a service like PayPal that doesn’t allow you to add your Google Analytics tracking code.
Option 2: Cross-Domain Tracking
But what if you need to know what a visitor is doing on the third-party or partner site? For example, if a visitor is converting on the external site (again, to fill out a form, purchase something, apply for a job, etc.) you absolutely need to set up something called cross-domain tracking. Adding the site to your Referral Exclusion List is not enough.
So imagine if I have a visitor on my site (I’ll call him Jared) who visits my main site, annielytics.com, and views 4 pages, then clicks through to a third-party site I’ve only excluded — awesometool.com — and views 3 pages, then comes back to my site and views 2 more pages. Google will only record 6 pageviews in my annielytics.com GA account. The 3 pageviews on awesometool.com are not included. However, if I have cross-domain tracking in place, the session will record 9 pageviews.
Also, with cross-domain tracking in place, if Jared submits a form on that third-party site, I can track it as a goal completion in Google Analytics. Same with any goal conversion or ecommerce transaction. It’s as if he never left my site because the two sites work as one.
Note: Even if you choose cross-domain tracking, you should still exclude those third-party domains by adding them to your Referral Exclusion List. It’s a built-it failsafe switch Google has given us, and I highly recommend taking full advantage of it.
So What Exactly Is Cross-Domain Tracking?
It All Starts with a Cookie
I can almost see your eyes roll to the back of your head. Fear not. I’m not going to bore you with the technical minutia of what a cookie is, how it’s stored in browsers, etc. Instead I’m going to use an analogy most can relate to: the Bridge of Death from Monty Python and the Holy Grail.
So, in simple terms, let’s say our visitor, Jared, comes to my site. He is assigned something called a client ID (Visitor ID in Google Analytics Classic). When he leaves my site and goes to another site that uses Google Analytics, he is assigned a new client ID that’s unique to that site. That’s the one first-party cookies work. You can only track a visitor’s online behavior on your site.
The Cookie’s Quest
If I use third-party tools that take visitors off my site onto an external site, the cookie that gets dropped into Jared’s browser faces challenges much like Sir Lancelot when he came upon the Bridge of Death.
His objective was to traverse the bridge without falling to his doom. But first he had to get past the troll. In our illustration the troll that guards the bridge is none other than ….
There is one thing Google wants to see: that the domain of the page Jared is coming from matches the domain (also called the hostname) of the page he’s clicking through to. If they match, Jared’s client ID will remain consistent. (Much easier than answering three elusive questions!) If not, you start from scratch with a new cookie unique to that site.
There is only one thing that will satisfy the gatekeeper in lieu of matching hostnames. It’s a single parameter that gets attached to the destination URL and carries all the cookie data with it. It looks something like this:
http://www.mypartnersite.com/?_ga=1.194668077.1445201766.1439118116
Aside: If you think that looks scary, you should see the cornucopia of parameters Google Analytics Classic uses:
If this mystical parameter is not offered as a sacrifice to Google, the cookie will drop. Die. Crumble. Make like a Pidgey and disappear in a poof.
How Does The Cookie Pass Unscathed?
To get this magical _ga parameter that has the power to satisfy the troll, you must take two steps:
- Install your Google Analytics tracking code on the third-party domain.
- Set up cross-domain tracking to carry the cookie across the bridge from one site to the other.
Back in the day we had to attach a piece of JavaScript code to every link that points to the third-party site and every link on the third-party site that points back to your site. Same with forms. It was a red-hot mess.
With Universal, Google made it much, much easier to set up cross-domain tracking. You just add an extra snippet of code to your Google Analytics tracking code that tells Google the domains you want to track as one site. It looks something like this:
Then make sure all the domains — or subdomains — you want to track are using the same code.
For a deep dive into the technical details, check out this implementation guide on Google. You can also use Google Tag Manager to set up cross-domain tracking.
How to Test Your Cross-Domain Tracking
The name of the game when testing to see if your cross-domain tracking is set up properly is to check to make sure the client ID remains the same when you cross from one domain to the next. If it does, congratulate yourself. You’re a badass. If it doesn’t, fire yourself. (I’m kidding!) It just means you need to go back to the drawing board and tweak your code.
My favorite tool to do that is the Google Analytics Debugger Chrome Extension. When you install it, you’ll want to navigate to your site and open up the Console tab in your Chrome: Ctrl-Shift-J (Mac: Command-Shift-J). Then look for the client ID (clientId).
Next, cross over to the second site. With Chrome Developer Tools still open to the Console, check to make sure the clientID doesn’t change. Take note in the example below the clientId did not change.
You can see the clientId matches.
You can also just use Chrome Developer Tools by navigating to Resources > Cookies > [select site] > _ga.
Finally, you can also use the Google’s Tag Assistant Chrome extension to do this testing.
Again, if you’re still on Classic (tsk tsk), you will be looking for the Visitor ID instead of clientId.
What About Subdomains?
You do not need to set up cross-domain tracking in order to track across subdomains on your own site. The Google Analytics cookie moves from subdomain to subdomain without issue.
My $0.02
Try to wean your site off of third-party tools, especially tools that are stuck in the dark ages and don’t allow you to add your own tracking code (ahem, PAYPAL). I know from firsthand experience how daunting it is to set up your site as an ecommerce site and to eschew tools that make many tasks much easier. But, in the end, being able to own your own data is [usually] worth it.
Christopher Whalen says
Thanks, Annie. Nice post.
What would you recommend doing if you can only add the standard Universal Analytics snippet to the third-party site (e.g. for event registrations: I’m looking at you, Active Network) without any customization for cross-domain tracking? I also don’t have the option of using GTM on the the third-party site.
Would I be better off using a different Google Analytics property ID on the third-party site if I can’t set up cross-domain tracking with my main site?
Annie Cushing says
It depends. If you send visitors to that site mid-session, and they come back to the main site to convert, you’ll want to add the site to your REL to preserve the referral data for the conversion. If you want to be able to track all of their behavior on the third-party site, it could make sense to use a separate property. But if your conversions take place on that third-party site, all of your conversions will be attributed to your main site.
Obsy says
Thanks for your post and your great site !
Annie Cushing says
Happy to help!
Matt Lawry says
Hi Annie,
Great post, love your use of graphics. I have noticed that on our website conversion rates have decreased. This drop coincides exactly with when we added Paypal to the exclusion list.
Should I be setting up this cross-domain tracking as well?
Thanks!
Annie Cushing says
Adding PayPal wouldn’t have caused this. In fact, reassigning the conversions from PayPal to the real sources would increase the conversion rates for those sources.
Samuel says
Hi Annie,
Thanks for a great great post and also explaining the problem and offering a solution. I however would like to correct / add one thing. In our case, our subdomain was not passing along the same client ID. So I had to implement the cross domain tracking solution.
Best
Annie Cushing says
Are these subdomains set up in separate properties? If so, setting up cross-domain tracking defeats the purpose of setting them up as separate properties (which is usually to minimize sampling). I would make sure you’re using the same GATC (GA tracking code) in all of your subdomains. If that’s not the case you have an issue causing your cookie to reset. Either way, it’s much better to get to the root of the issue rather than recommending this as an alternative as it’s a very circuitous fix that introduces risk I wouldn’t recommend other site owners assume.
Samuel says
Hi Annie,
Yes, they are set up in two different properties. My predecessor made the setup. But I see your point. So, you would recommend that we’d change the GATC to the same as the root domain?
Annie Cushing says
Yes, I would.
Jenny Rodriguez says
Hi Annie ,
Thank you for your great article, very detailed
I have a 3 step booking, Step 1 on the first domain, Step 2 on the second domain and finally the confirm page back on the first domain. I set up anything like you wrote on the article however, the day after when I checked on google analytics a huge portion of traffic and conversions are changed to referral /medium. And I couldn’t figure out why .
Do you have any insight for that ?
Annie Cushing says
Happy to help! Re: your q … Is the second domain included in your Referral Exclusion List? https://annielytics.com/blog/analytics/referral-exclusion-list-google-analytics-explained/
Jenny Rodriguez says
Yes we did put the second domain in the Referral Exclusion List. Before we set the tracking ID on both domains with ID tracking of the fist domain UA-first domain. However, we couldn’t record any data from the step 3 confirm booking (everything is 0) and then we had to change the code on the second domain to the tracking ID of its own. So the code on 1st domain is UA-first domain, code on 2st domain is UA- second domain then the data of step 3 started showing up again but all change to referral source and now the step 2 couldn’t record data
Annie Cushing says
I’m not able to troubleshoot this issue without seeing the accounts and sites. If you wanted to schedule a hangout, I could walk through it w/ you. https://annielytics.com/services/purchase-hangout/
priya raj says
Hi,
I have 9 subdomains with different countries for example- site.example.com/uk, site.example.com/us etc..Should i add all my 9 subdomains to the self-referral exclusion list? Right now i have added the main site http://www.example.com in the self-exclusion list and I have cross-domain tracking activated as well. Pleas guide.
Annie Cushing says
The examples you gave here are subdirectories, not subdomains. But you don’t need to list subdomains in your REL unless you track your subdomains in different properties.
priya raj says
No I have one property http://www.mandy.com and then subdomains like actors.mandy.com, crew.mandy.com and so on ( multiple views)….My subdomain views show self-referral traffic.For Example- referral traffic for Actors.mandy.com/uk includes traffic from actors.mandy.com ..Should i exclude them? Sorry if i wasn’t clear earlier?
Annie Cushing says
Then you don’t need to list subdomains in your REL.
priya raj says
Thanks for your response Annie.
Lisa Macqueen says
Hi Annie, First off, thanks for this amazing blog, and for continuing to reply to all the questions..!
So my question is this. We have a commercial cleaning business (Janitorial/office cleaning etc), we advertise on FB, SEM and we rank very well for SEO. All of our conversions are where people request a quote using our quote form.
The quote form is hosted in Infusionsoft, and because of this, I just can’t see accurately where my traffic is coming from and which ad is working or not working. So I never truly know what the ROI is and it’s driving me crazy!!
What would you recommend to fix this? I’ve looked at a few third party tools which really start to get expensive over time. Surely there is a way to get this information easier (and cheaper) than that?? Any advice or suggestions you have would be great, thank you so much..
Annie Cushing says
Hi Lisa, is the thank you page for the form not hosted on your site? As long as you have a thank you page you can easily track form submissions in GA.
Alex says
Hi Annie
Thanks for an excellent post.
I have hotel website+booking engine. Both installed GTM with same GA code.
I try to fix for a long time problem with direct/none conversions (all conversions).
Checked cookies, it’s ok, i see the same _ga for on site and on booking engine.
Really don’t know what to check else.
Hope to your advice
Annie Cushing says
Have you set up xdomain tracking in GTM? Instructions: http://bit.ly/2XHcQ8F.
Robby says
Great article. I have a quick question we have a website that users start on then go to a third party then back to our site. I want to setup tracking so we know what is happening on the third party site. We have a GTM code on our site. For this to work do I have to convince the owner of the third party site to add our GTM code on their site? What if they already have their own GTM code? thanks!!!!
Annie Cushing says
Hi, Robby! They don’t have to set up your GTM code. They can just add your GATC (GA tracking code) to their GTM.