How To Set Up Cross-Domain Tracking with Google Tag Manager

Cross Domain Tracking for Google Analytics needs to be installed if you have two separate domains you want to connect to one Google Analytics account. We will utilize GTM to install this on our website and test if it’s working.

In this video, I’m going to show you how you can install Google Analytics cross-domain tracking with the help of Google Tag Manager. All and more coming up.

Hey there measure geeks, Julian here back with another video for you another tutorial on Google Analytics and Google Tag Manager. If you are new here, we’re actually doing

a live recording.And if you want to be online next time and ask questions, and definitely subscribe to our channel down below.

Today, we want to talk about Google Analytics cross domain tracking. This is a topic that trips a lot of people up because there are a lot of different things that actually go into it a lot of decision making beforehand. So I want to take it step by step and show you what cross domain tracking is all about. Let’s go into a little demo here, I have my demo shop, where I have Google Analytics and Google Tag Manager installed. As you can see Google Tag matches and salt. And it sends a page view on to our Google Analytics account, which we can then see inside of our real time reporting. So in our real time reporting, we should see

a new page view in a second, once we have reloaded this page, and our Google Analytics tag has fired. Here we go, we have a new Google Analytics page view.

Now what I also have installed is a connected website. So this is a website that I want to track into the same Google Analytics account here. And once I go over to this second website which is our demo, pay attention to the domain, it actually changes. We also sending with the same Google Tag Manager icon, which I have installed there another page view to Google Analytics into the same Google Analytics account. And we have a second page view. The problem here is that Google Analytics actually count two users that entered this website. The user is just one user because we went from one to the next website. But Google Analytics can’t recognize this user again, and doesn’t know that he actually entered the website from our connected website. Google Analytics hasn’t gotten any reference to this.

So we need to install something called cross domain tracking in order to connect this and

make this one user and one session. Otherwise, the user would be attributed differently to a different source because you actually have two users that would come two users in the session. So you would have also have inflated metrics as well. So cross domain tracking is something you would need to install in this case. But there are other cases where you don’t

have to install cross-domain tracking. So I have made up a little graphic here which is going to go from the start. Do you actually need to have cross domain tracking installed? And the first question you need to ask yourself is, do you have multiple domains that you have set up? Not multiple sub domains because sub domain tracking doesn’t actually need cross domain tracking. But different domains so does the part in front of the .com or the .de, or actually change? And if that’s the case, you might need to have cross domain tracking. But if you don’t have that part changed, then you don’t need it. As well as sub domain tracking. If there’s a sub domain like, you don’t necessarily need cross domain tracking. So no, you don’t need cross domain tracking if the domain doesn’t change. 

But if it changes, you will need to check the second question, do I want to send this

data to the same Google Analytics account? Do you have a these two pages, for example,

Google Tag Manager, or gtag or the analytics js tracking code installed, and they both have the same UA ID, so they’re sending the same data on the data to the same account in Google Analytics. If this is not the case, and you are sending data to two separate Google Analytics account, so you have two separate domains, and you have to separate Google Analytics installations, then, no, you don’t need cross domain tracking because you are not

connecting these accounts to one user in the same Google Analytics account. But if you’re sending this and you want to send this to one account and one account only, then yes, you might need to install cross domain tracking. There’s some more qualifying questions, are

users going from one to the other side, and then going back between them. So is there a back and forth between the two sides?

The other question you might want to ask yourself is, well, I have a third party, third party check out on my page. So the user starts on my page, but then goes to my third party Checkout and he converts there. Is that maybe a cross domain tracking that you want to install? Because you have two Google Analytics for the same property installed on these two domains, and you want to send this over then you would need to have the cross domain tracking installed and continue the session. Very important because we want to attribute

the sales later to the right source where the user originally came from. So ask yourself these two questions. If you have sub domains, then you don’t need cross domain tracking. If you have not two domains, then you don’t have to have cross domain tracking. And if you are sending data to completely separate Google Analytics properties, then you also don’t need cross domain tracking. But if this is all true for you, then you might want to install cross domain tracking. And I’m going to show you how to set this up right now. 

So how can we connect our two domains, the demo, and the to each other? How can we connect them and to cross domain tracking? Well, on these two pages, we actually have Google Tag Manager installed. So on this page, we have the same Tag Manager account as on our demo which is quite convenient because we can control both tracking codes here from one Google Tag Manager account. But you couldn’t even do this if you have to Google Tag Manager accounts, you just have to repeat those steps. And those two Google Tag Manager accounts. Right now we have just one Google Tag Manager account which is quite convenient. And as you can see, we have our Google Analytics page, you tag that sends the data over now this tag, we need to install something to enable cross domain tracking, these are two settings. How can you install these settings, you would first of all need to click on enable override settings in this tag, then click on more settings. And then the more settings we have, first of all, our cross domain tracking and this

is the link of functionality. This link of functionality will enable something to attach something to your links. And what you need to do here is tell Google Tag Manager which domains should be linked in our case that would be and

The second setting that we need to take care of is the field to set option. And in the field to set option we need to enable a field that is in this list down here called it’s called allow linker.

And allow linker needs to be set to true. This is the receiving end, once the Google

Analytics code sees the identifier and the URL, it will transfer and send the right data over to Google Analytics. So this these are the two settings that you need to enable. Now, one thing that I need to mention is if you have multiple Google Analytics account, multiple Google Analytics tags installed on your Google Tag Manager account, you might want to install this directly into your Google Analytics settings variable. So I have a settings variable here. And we could also install this into our settings terrible, so we don’t have to change around all our Google Analytics text. So for example, if you have an event tag, transaction tag, or any kind of other texts, you would need to install cross domain tracking, obviously, also in those tags. But if you have a Google Analytics settings variable already enabled, then you can install

this only once.

So let me repeat this. If you if you get rid of all of this, oh, well can just click discard. And we want to install this now into our settings variable directly, we can just go over to our settings terrible, and the variable menu and repeat those steps. Because these are all the settings we have here available as well. So on the cross domain checking section, I’m going to go with demo and the And then I’m also going to add the field to set option which is allow linker and set this to true. So let’s save this and this will now be installed automatically into all our Google Analytics tags, or don’t we just have one tag.

We’re going to refresh our browser, our preview and debug mode and our browser. And now we should have this installed. Now what does this actually do? The cross domain tracking will look through the page. Look at all the links that are on the page. And if one of those links is going over to this connected the domain so our demo, it will attach the session information to the link itself. If we now click on blog we see this little query strings attached to the URL. And this query string gives over the right session and user information to this Google Analytics code that will then be able to reconnect you and count you as one user.

Now, there are two users here right now, as we have entered the website before and the

session only expires after 25 minutes. So we are still here on this to the user mark. But we can test this by going over. And what I want to do is, first of all, delete my cookies, not that we have created predicting information here. So I’m going to get rid of my Google Analytics cookie, this is how Google Analytics actually recognizes me, and identifies me again, going to go over to the demo shop. And also here, I’m gonna delete my cookies really quickly. Okay, we have a lot of Google Analytics stuff here, we’re gonna get rid of. All right, and now I’m going to enter the website with a query string, which are UTM parameters, I’m going to just go with the UTM test here. Nope, just doesn’t work. I’m just gonna go with here we go UTM test. I’m going to enter the website new again and Google Analytics should now recognize me and say, okay, there is a new user from the traffic source test, as I have entered this into our well into our UTM source, right here. Resources not available. Reload this. And it should show me that there’s a new user from our test right here. Now I can filter on this user. So one user came from test. And this is me, I can identify myself this way.

And I can also now see where this user is actually at. So if I go back to overview here, we have one user from the medium test. And do you goes over to the T shirt section, we should see our a new page view and our URL should be newly reloaded. Sometimes this takes a second. But we have our Google Analytics, tracking code set off. And now we can see this user is now on T shirt. We’re gonna go with all sections here. So we are now on the T shirt section. And now I’m going to go over to the blog itself. And our session should be transferred over through this query string, Google Analytics should re-recognize this included into our Google Analytics tag send the information of, and we should have a new page view here that is the same user still. So we just have one user, and he is now recognized as one session, one user, and he is on the right page. So now we have installed cross domain tracking with that help of Google Tag Manager.

So just to recap, really quickly. You need to be thinking about one to install cross-domain tracking, do I actually need cross domain tracking, go through the crucial questions that you need to ask yourself. Second, you would need to then just simply make alter the Google Analytics tracking codes to include and link up these two domains in Google Tag Manager.

This is pretty easily done. You can also do this obviously, in the Gtag or in the analytics JS tracking. But there are some other instructions that you would need to utilize. And I’m going to link up some resources down below where you can find this out. All right, this is it with this week’s video on cross domain tracking with Google Tag Manager. If you liked this video, then definitely give us a thumbs up and if you haven’t yet, and consider subscribing to our channel right over there because we bring you new videos just like this one every week. Now, my name is Julian till next time.


Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
Inline Feedbacks
View all comments

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.