Tutorial // Cross-Domain Tracking with Google Tag Manager
Articles,  Blog

Tutorial // Cross-Domain Tracking with Google Tag Manager


Hey there! I’m Benjamin from Loves Data. In this video you’re going to learn how to
track people as they navigate between different websites using cross-domain tracking. I’m going to show you how to set up cross-domain
tracking using Google Tag Manager and Google Analytics. If you don’t set up cross-domain tracking
then you’ll see a new session reported as someone travels from your first website to
your second website. And you’ll also see the first website show
up in your Acquisition reports. This can be a real problem if you expect people
to convert on your second website. Let’s get started… We’re going to be implementing cross-domain
tracking on my two test domains. So we’re going to track people as they navigate
between lovesdata-test.com and lovesdata-test-two.com. Let’s start by looking at what happens if
we don’t implement cross-domain tracking… When we open the first domain we’ll have a
user reported inside Google Analytics… We can navigate to the real time reports to
see this… So here we can see a single user reported… Now let’s go back to the website… And let’s navigate to the second domain… Now let’s take a look at the real time report
again… We can now see that we have two users reported. Both domains have the same Google Tag Manager
container and the same Google Analytics tracking code, but Google Analytics is seeing me as
two separate users. So what we need to do is configure cross-domain
tracking so that we get accurate data in our reports. Let’s head to Google Tag Manager to do this… Now I’m guessing you’re already using Google
Tag Manager to deploy Google Analytics on your website, so here we can see there is
an existing Google Analytics tag, so let’s select the tag to edit it… Now we just need to make a few modifications
to the tag. The first thing we need to do is select the
option to ‘Enable overriding settings’… This gives us access to additional configurations
we can make to the tag. Now we’re going to select ‘More Settings’,
then ‘Fields to Set’ and click ‘Add Field’. We need to enter allowLinker as the ‘Field
Name’ and ‘true’ as the value. This tells the Google Analytics tracking code
that we want to automatically modify links on our website so that when people click them
it will synchronize the Google Analytics cookie on the other website. Now we need to add another field… And we’re going to enter ‘cookieDomain’ and
then ‘auto’. This tells Google Analytics to automatically
choose a cookie domain to use when we track users. Scrolling down we need to look for ‘Cross
Domain Tracking’ and in the ‘Auto Link Domains’ field we need to enter the domains we want
to track. For our example we’re going to enter lovesdata-test.com
comma lovesdata-test-two.com. This tells Google Analytics these are the
domains we want to use for cross-domain tracking. I’ve entered this directly into the field,
but if you’re likely to reuse this value in another tag inside Google Tag Manager you
could create a new variable with the value instead. Now since I also have a form that submits
between the two domains that I also want to track I’m going to set ‘Decorate Forms’ to
‘true’. This allows you to automatically track form
submissions across domains. That’s it! Now I’m going to save my tag… And publish the container. Let’s travel back to the website and refresh
the page… Now let’s head to Google Analytics… And we can see one user reported in the real
time reports. Now let’s head back to the website… And let’s click the link to the second domain… You’ll notice in the browser’s URL bar there
are some additional characters. This is how Google Analytics synchronizes
cookies for our users between the two domains. It passes the cookie value, which is our unique
identifier (the client ID) to the other website. This is then seen by Google Analytics and
used to understand it’s the same user traveling between the domains. Now let’s head back to Google Analytics… We can now see that a second pageview has
been reported, but our user count is still ‘one’. This means we’ve successfully configured cross-domain
tracking. So that’s how you can setup cross-domain tracking
using Google Tag Manager. You’ll now be able to see the original acquisition
source even if people navigate between your two websites. Are you using cross-domain tracking with Google
Analytics? I’d love to know! Let me know and leave your tips in the comments
below! If you found this video helpful, then please
like it, so I know to make more videos like this. See you next time!

39 Comments

  • Ateeq Ahmad

    Not only do I appreciate the learning, the presentation style is so calm and serene that it is almost like therapy. Thank you!

  • Jessica Carl

    Hello, love the tutorial!
    I must be missing something though, because I can't get it to work. I have 2 separate domains. One is a domain (A) we create landing pages on. The second domain is a 3rd party platform (B). Both domains have their own GA and GTM accounts setup for them.
    I added the GA property from B to A as a second GA property on the site (I want to see landing page data combined with data from the platform use after clicking the CAT). I followed your video steps in GTM B. When that didn't work, I also followed the steps in GTM A for the 2nd GA property I setup.
    When I click the link on site A to go to B it's still tracking 2 users instead of 1 across domains.
    What am I missing or doing wrong? Thank you

  • Stefaan Quackels

    Thanks for this. I have a question though: would you have any idea how to track a page-view event from one domain to the other? The context is that a conversion actually happens on a separate domain where we can add a GTM-container.

  • Rodrigo Arias

    Hi Ben, Do you know if there's another way to make sure that the sessions don't split apart from checking the real life reporting? I have a lot of users in my website, so its hard to tell that way.

  • Get Found Madison

    Amazing. Thank you! Do you know if both domains need to be using GTM for this to work? We're trying to set up cross domain tracking with Eventbrite.

  • TRECS Web Team

    great video, i especially liked the fact that you explained what the purpose of the variables were. I watched another video, that while more comprehensive, did not explain this.

  • Michael Charters

    Hi Benjamin, great video! May I ask you, I have 2 domains which I am linking as per the video; however, the goal which is reached and recorded in Google Analytics is not being imported into Adwords despite having linked the accounts and using import conversions within AdWords. I wonder if you already have another excellent video on how to import Analytics conversions into AdWords including the nominated value amount of the goal (set within Analytics) so that this value is set against the AdWords campaign/ad which will therefore allow me to set a ROAS bidding strategy.

  • Karl Sultana

    Is it possible to remove or hide the extra characters & numbers added automatically to the URL of the domain?
    I rather my visitors see domain.com instead of domain.com/ga-2.2-432432432432-432432-432432-432432

    Thanks!

  • Swapnil Majgaonkar

    Hi Ben, Great video. Helps a lot.
    I have one doubt. I need to do cross domain linking. But my GA code is not set via GTM.
    We have directly put it on the site few month ago.
    If we put the universal tag now in GTM. and remove from source code. will it hurt the back data of the site.
    Many thanks in advance.

  • Javier Sancho Piqueras

    great video but just a question. Why you enable override tag? You can do it in the google analytics settings variable. Am I wrong?

  • 韩学颖

    Thank you for the tutorial. I have a question, I have 2domains. A and B are using same GTM code and GA code. After setting, tag assistant told me 'Same web property ID is tracked twice. ' However, I can see the additional characters behind of the domin. So is there something wrong, or it's correct.

  • Leap13

    Nice Video 🙂
    I have one question if you don't mind, should I add the same Analytics tag in both sites to work? Accordingly both will have the same UA code?

  • Taylor Smith

    very helpful video!

    I do have a few questions i hope you can shed some light on this!

    example/overview:

    I have 5 different domains;
    domainA.com
    domainB.com
    domainC.com
    domainD.com
    domainE.com

    we have user A that will go to domainA.com to login to their account…… and we have user B that will go to domainB.com to login to their account……… however , both user A and user B will use/"share" domainC.com, domainD.com or domainE.com to convert/purchase .

    domainA.com is one property and domainB.com is the second property in GA

    Would domainC.com, domainD.com and domainE.com each have two different GTM containers on them to track ?

    Current issue is that when users goes from domainA.com to domainC.com to purchase, its counted as a new session/new user and obviously want to fix that so we can track users from start to finish.

    how would you/anyone recommend to properly set this up so that user A and user B are tracked from beginning to end?

  • Environmental Jobs Network

    Thank you for helping me crack this, finally, your step-by-step approach ensured I didnt give up. Thanks so very much 🙂

  • Sam Silk

    Do I need to do this on BOTH websites in a scenario where the path from one of the domains to the other is "one way"? I ask because I have a cross domain issue with a cart embedded on my website (in an iframe). The tracking ID is the same for both the cart and my website (or so I think… ) but I don't have access to the Google scripts on the cart's side. I receive events from the cart but no conversion data for my paid ads, and there is the "double session" issue: one for my website and another one as soon as there is an interaction with the cart.

  • Frédéric Durand

    I spent too much time reading articles about this…. I should have found this video first… This is very clear. Thank you!

  • Andrew Lukac

    Hi there, on my google tag manager account I can't see 'Cross-Domain Tracking'. I just have 'Advertising' and underneath is 'Advanced Configuration'. Please help, Regards

  • Upstate Bill Tracking

    I have the same question as others. The one place I'm not clear on is do I need two separate google tag managers for each domain? Or should I use the same google tag manager for both domains? If I need two google tag managers, do I need to do this for each container?

  • Carolina Maldonado

    Hello Ben, I would like to know if the cross-domain tracking will work in the following scenario: We have a promotional website for a particular payment method, there we promote different e-commerce. We also have a web checkout were we process the purchase of the customers in these merchants. If a customer lands on our primary website (page 1), then he moves to a third party website e.g. retail stores, and then he goes back to our web checkout page (page 2) to make the payment. Are we gonna be able to identify this customer using the cross-domain feature or the client ID? Thanks for your comments.

  • Harvinder Singh

    Hello Sir,
    Thanks for this useful video

    can you tell me how can I scrap the image URL from the source page?

    like

    <div class="et_pb_section" >

    <span class="et_pb_image">

    <img src="https://image.png" alt>

    how can I pick an image URL from Dom Element so that I can add it into the review schema to complete my product review element?

    thanks

  • Eddie Gega

    Boom straight to the point. No Micky mouse talking, just a true professional guy giving his clear solution to tricky problem. My Tag manager on the browser gave this message (Same web property ID is tracked twice.) Soon after the video i refreshed the site and problem was solved. Thanks Benjamin

  • Townscript

    Thank you for the great video. I believe in your case the container / Google Analytics is same and the websites are different. We want to do cross domain analytics of two different websites with their different Google Analytics. How should we do it?

  • Brad Holly

    Hello, followed step-by-step and I am still getting a self-referral issue when it comes to the acquisition report. Also, I don't get the cookie string in the URL like you did… However analytically the URL path is looking good. Any ideas?

  • Massimo Di Giovanni

    hi there … great video .. but a question .. if i use this tag manager method is not needed to create different view in analytics for each language with filters? right?

Leave a Reply

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