Cross-Domain Tracking with Google Tag Manager
Articles,  Blog

Cross-Domain Tracking with Google Tag Manager


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 blog.com, 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
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 the.co.uk 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 blog.amazon.com,
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 shop.com, and the demoblog.com 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 blog.com 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 demoshop.com and demoblog.com. 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 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 shop.com and the demoblog.com. 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 blog.com, it will attach the session information to
the link itself. If we now click on blog demoshop.com 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 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.

38 Comments

  • Chris Griffin

    Great instructional video as always! When implementing this, do you recommend changing the settings in GA to show the full page URL in reports (https://support.google.com/analytics/answer/1012243?hl=en) in order to differentiate between the home pages (or any other page with matching page paths) on the connected sites? This is what we've done in the past, but I wasn't sure if there is a better way of doing this now.

  • Jesse Walker

    If the users path is sourcedomain.com to targetdomain.com then back to sourcedomain.com, how do you make sure the User ID is carried through all three steps?

  • pritateking luffy

    @measureschool Hey julian, bit of an older issue but is there any update on the checkout situation?

    Installed gtm as you recommended 6 months ago on a video and no luck with triggering on checkout pages 🤦🏽‍♂️

    PLEASE advise ☺️

  • George Zhu

    Seems like this is only applicable if the URL's on the cross domains are different, else visiting the shop & blog is always going to return /?

  • Jared Newnam

    Hi Julian. I currently have cross domain tracking set up, and I have it set up on sub-domains. Someone a long time ago, told me to set it up that way because my sub-domains careers.mywebsite.com and ecommerce.mywebsite.com are hosted on different servers than our root domain mywebsite.com.

    My question is… If I remove those sub-domains from my Cross Domain Tracking, but I leave the GTM tracking code on the pages, will these still track? Or because they're hosted separately, and DNS is set up differently, should I leave it the way it is?

  • Jared Newnam

    Hi Julian. Another question – I have all my Auto Link Domains set up in the Variable for Pageviews. Should these domains be set in the tag instead, as your video suggests?

  • Aerial Artistry

    Hello Julian, do you do consulting or you can recommend someone? I am one man show running small talent agency company and I am looking for tech to help me to set up correctly and if there anything else missing with Adwords Remarketing Analytics tag manager- Crate audience to help me to for my company to have a better results 🙂. I hope to hear from you have a nice day Tatyana

  • Joseph Villanueva

    Is there a way set cross domain tracking cookies? I want to be able to set a 1st party cookie on example.com and then read the same cookie on example2.com. Thanks In Advance!

  • JohnL

    Why would you not need cross domain tracking for blog.example.com and offers.example.com, if you have a GA property for example.com?

    Is one way to check that if you see that it counts numerous sessions and users as you navigate between them?

    Thanks!

  • Emii Trang Le

    So helpful. Thank you for the tutorials as always. One question: I’m currently setting up different GTM container for each microsite and domain but they’re part of one brand. Is it better to use the same GTM container for cross domain tracking to work? Thanks for your help!

  • MeasureSchool

    One step I forgot to mention in this Video: You also should add the Domains you are cross-domain tracking into your Google Analytics Referral Exclusion list. Go to your Admin section in GA and click on Tracking Info. There you will find your Referral exclusion list. Add the domains you entered into the Auto Link Domains field just like we did it at 7:34

  • August Teleg

    Question at @4.17 did u really mean SAME ACCOUNT? and not SAME Tracking ID? I am confused whether I should use it for a website that has only one Property (main website) on GA. But has multiple domains (com.au, com.hk)

  • Becki Irby

    Thanks for the video! Question – is the process the same if you do not own both domains. Example: a popular website partners with a purchasing provider, and while they partner they are separately owned. A user enters Domain 1 and chooses to make a purchase by clicking on embedded links that lead to Domain 2, where the user completes the purchase process. NOTE: The Google Analytics Key would be the same one on each domain. In this scenario, would everything you describe in your video still be true? If not, what would change? If yes, are there additional steps that you can recommend to me?

  • Ann Wang

    I'm curious about what has mentioned in the video, if my two domain have install two different GTM (with same GA property), just by taking the same steps as mentioned in the video will still attribute the correct data to GA account?
    How about if A domain has install GTM tag, B domain install GA tag, will it still work?

  • Esteban Clouthier

    What happens if a user wants to share your page by copying the url and the url has the code /?_ga=2.51366945.18161885.8358985-12345623.98765432 ? When the user's friend opens the link with that url, will the friend count as the same user?

  • Luca Pecchiura

    Thank you Julian! But, how to make it works with "events"? I follow the instructions and it works only if I use "Pageview" as the Track Type of the Google Analytics property in Tag Manager. If I use "Event" as Track Type, it doesn't works and it counts the same users twice. How can I do if I want to tracks my users actions with events in 2 different domains sites?

  • Hurty18

    I was briefly hoping, that you got rid of the annoying intro music 😀 Well if you need a new one, I can create one for you. And thank you for this video!

  • Marc Bislin

    Hi – very good video, thanks! we have a case where we have various domains and as well as that for every domain a different google tag manager. So we tried to follow the same steps on every GTM container, but somehow it does not work. Do you know, if we would need that case differently?

  • Anzila Suriya

    is www.example/blog considered a subdomain or a domain?

    do i need to setup cross-domain tracking for urls like these?

  • Jakaria al Mahmud

    Hi Julian,
    have a related question, how can we do this, like if a user browses through demoshop.com to demoblog.com then demoblog.com's GTM script should work normally but if a user directly visits demoblog.com then GTM script shouldn't fire/work.
    Thanks!

  • Randal Whitmore

    When doing this, your homepage url sessions will surely be inflated when you have different domains using the same GA tag, ie someone visits one website and then the other in your example, you’d have two homepage visits (displayed as “/“ in page behaviour). How do you separate these to prevent skewing homepage visit data?

  • Tristan Durand

    Thanks a lot for the content you put out. It's very helpful.
    However, after doing what you teach in this video it's still not working for my scenario, let me explain…

    I run a Shopify store and use the Shopify Buy Button. The frustrating thing (it's an understatment) with that Shopify Buy Button is that it brings the visitors to a mystore.myshopify.com pop up (instead of staying on mystore.com).
    to me it's 2 problems:
    – it doesn't look very trustworthy to the potential customer when they see the domain changes all of a sudden (and it reveals that you have a Shopify website)
    – it shows as 2 different users on Google analytics (the exact issue you talk about on your video)

    I did what you describe in your video, unfortunately, still 2 users on GA live view… Huh…

    The question is: How can we link the same GTM to both mystore.com and mystore.myshopify.com?
    I think that's where the problem is from for us.

    Any help is appreciated!

  • Randal Whitmore

    Thanks again Julian. Having a couple of issues in my implementation and I've got a couple of questions:

    1. Would this setup still work if demoblog.com in your example was redirected from demoshop.com/blog in the main navigation or would you need to do something different with the linking domains in Tag Manager?

    2. Does the same Tag Manager container need to be installed on both sites or would it still work if demoshop.com had Tag Manager with GA installed and demoblog.com just had GA installed (without Tag Manager)?

  • Плотникова Марина

    Hi Julian,
    I have added the cross-domain traffic as explained in the video, but I do not see the changes in real-time Top Active Pages when I go through one page of sub-domain to another.
    I see them only when I refresh the subdomain page, which is not right. (To mention, I don't have the same problem when I see the same domain on separate Google Analytics account which had been made only for the subdomain).

  • Tomas Kristiansen

    Does anyone know how cross-domain tracking works if you use an external service/app which you don't own (the domain)?

  • Mohsin Nagi

    @measureschool hi julian i have question, we have 3 domains and our cross domain linking works perfectly but when we move to 3rd domain with events tracking it changed the medium of that flow move it to direct , for example when a customer coming from paid and comes on 2nd domain and clicks on event which is created on target domain move to 3rd domain its loses it medium and events starts coming in direct medium. How can i resolve this matter with event tracking through cross domains. I think something is missing can you help its urgent. we are using GTM for all that and we have same GTM codes on all 3 domains.

  • nayan m

    Hey Julian, I am following most of your videos on youtube about google anaytics and tag manager. I would like to take up your course on udemy. But i want to know if there is a demo account where I could set and check the tags if I take the course on udemy.

  • PHvente SEO

    Hey Julian, I have a problem with the cross domain tracking configuration. I am able to follow my session through both sites no problem and it shows that the session's source is my UTM in the real time section, just like I want it, except that when I test out my conversions (goals) it seems like it gives credit to a referral source ? Any tips on how to fix this ? Thanks !

  • Gopi Mundkur

    Hi Julian, I did a 301 permanent redirect of my old domain: https://hakunamatatatourism.com to a new domain: https://tanzania-wildlife-safaris.com What should I do? Can you kindly advise? Thank you in advance for your valuable advise. Gopi Mundkur

Leave a Reply

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