Cross Domain Tracking with Google Tag Manager | LunaMetrics

Cross Domain Tracking with Google Tag Manager

/

blog-cross-domain-tracking-gtm
If you want to track multiple domains within the same Google Analytics account, you’ll have to make some modifications to your tracking code. Out of the box, Google Analytics will not properly track a user between these two domains. Initially, cross domain tracking was a huge pain – you’d have to manually tag links with special attributes in order to get the job done. Universal Analytics made things significantly easier with the linker.js plugin, which allows for cross domain settings to be configured when the tracker is being created.

Google Tag Manager has made things even simpler; I regularly help attendees of our Google Tag Manager trainings get their cross-domain needs sorted out in just a few minutes. It’s that good. Here’s how you can configure cross domain tracking with Google Tag Manager.

IMPORTANT: Before you get started

If you are trying to track users across many different subsections of a single domain, e.g.:

  • shopping.lunametrics.com
  • www.lunametrics.com
  • admin.lunametrics.com

You are not interested in cross domain tracking, you are interested in subdomain tracking. The best way to accomplish this is to add the ‘cookieDomain’ Field To Set and set it’s value to auto. That will instruct the tracker to make the cookie available to all of the subdomains that it can. IMPORTANT: Verify that your domain is configured in your Referral Exclusion list – (lunametrics.com in our example above). For more information, check out our guide to cross-subdomain tracking.

Step #1: Create An Auto Link Domains Variable

Create a new Constant Variable and set it to a comma-separated list of all of the domains you’d like to track in your property. It should look something like this:

  • If you want to track links to all subdomains of domain, enter just the hostname without any subdomain, e.g. for admin.example.com and www.example.com, enter example.com
  • If you want to track links to just one specific subdomain of an external domain, enter in the full hostname, e.g. for shopping.external.com but not www.external.com, enter in shopping.external.com

Step #2: Add The Auto Link Domains To Your Pageview Tag

Next, you’ll need to enable Cross Domain Tracking in your Pageview tag. To do this, open your Universal Analytics Pageview Tag in Google Tag Manager. On the ‘Configure’ step in the tag creation wizard, click the More Settings dropdown, then the Cross Domain Tracking menu beneath that. In the Auto Link Domains field, enter {{Auto Link Domains}}. It should look like this at this point:

This tells Google Analytics to decorate any links it sees that point to those domains with special parameters for tracking users cross-domain.

Step #3: Add The allowLinker Field To Set

Now that Google Analytics knows which links to decorate, you have to tell it to use those special parameters when it sees them in a page path. To do this, you’ll want to scroll up to the Fields To Set dropdown and expand it. Click Add Field, and then enter allowLinker into the Field Name field that appears. In the accompanying Value field, enter true. It should look like this:

You’re 90% of the way done, but don’t publish just yet. You’ve got one more VERY important step to take.

Step #4: IMPORTANT: Update Your Referral Exclusion List

The Referral Exclusion List is a list of domain names that Google Analytics treats as Direct traffic instead of referrals. When a user visits your site from a domain on the exclusion list, Google Analytics rewrites their source/medium information to be (direct)/(none) instead of whatever it would have been. If the user already has a session that has not expired, Google Analytics will ignore the new referring information entirely and continue the session as is (Note: this applies to subdomain tracking, too).

This is important: if you do not add all of the domains you set in your Auto Link Domains variable to your referral exclusion list, your cross-domain tracking will not work as expected. Google Analytics will correctly attribute the session to the same user that it was tracking on Domain A when they arrive on Domain B, but it will start a new session with Domain A set as the source/medium information. This is commonly called a self-referral (and is probably why you’re here in the first place).

To update your Referral Exclusion List, open the Admin Panel in Google Analytics, then select the Tracking Info menu item from the Property configurations. Select the Referral Exclusion List menu item.

Screen Shot 2015-06-09 at 3.09.09 PM

In the Referral Exclusion List interface, click Add Referral Exclusion and enter in each of the hostnames you’d like to exclude.

Screen Shot 2015-06-09 at 3.10.34 PM

If you only want to exclude traffic from a particular hostname, or you’ve got thousands of domains you want to exclude, check out Dorcas’ post on advanced Referral Exclusion List techniques.

Step #5: Testing

We now need to test and ensure our Cross Domain Tracking is configured properly. In your Universal Analytics Pageview Tag, under the Advanced Options dropdown, set the Debug Mode Option to {{Debug Mode}}, then save it. Debug Mode is just a built-in variable that can be enabled.

Click the ‘Preview’ button, clear your cookies on your homepage, then reload your homepage with special source and medium campaign parameters attached, e.g.:

http://www.example.com/?utm_source=cd_test&utm_medium=cd_test

Click on a link to one of your other domains. When the page loads, look in the URL bar of your browser and look for a bunch of extra parameters attached to the link, like this:

http://subdomain.external.com/?_ga=1.210371479.3429707736.1432831029

Test #1 – Did clicking on a link to one of your auto-linked domains add extra parameters to the link? The example above is using Universal Analytics, Classic code will look a little different. If you don’t see extra parameters being attached to the link, then go back and check your Auto Link Domain settings.

This next part is a little more technical. We can use the Developer Tools in our browser to see extra Debug information that we just enabled. Open the Developer Tools Console on your browser (in Chrome, CMD+SHIFT+J on a Mac or F12 on a PC, in Firefox, CMD+ALT+K on a Mac and CTRL+SHIFT+K on a PC).

In the output, you should see the line Loaded Linker Parameter: 1242342241.144231251 (the numbers will be different in your output):

Screen Shot 2015-06-09 at 3.25.20 PM

Test #2 – If you don’t see this line in your console, then doublecheck that you’ve set the allowLinker parameter to true.

That’s it! Clear your cookies and close the page.

Finally, check your Analytics the next day, and create an Advanced Segment to only show Users with Source cd_test. You should see a single User, with a single Session, and two pageviews.

Step #6: Add A Filter To Prepend Hostnames (OPTIONAL)

If you’re tracking multiple sites in a single property, hits for all domains will be grouped by page path. What that means is pageviews of example.com/about-us and external.com/about-us will both be counted in a single row in the All Pages reports, /about-us.

To fix this, follow these directions to prepend the hostname to all of your page paths. Annie Cushing has written a good guide on setting this up. Note that this will affect your data going forward, so you may want to do this in a separate view.

Got questions? ‘Course you do. Leave me a comment below and I’ll get back to you.

Dan Wilkerson is a Software Engineer at LunaMetrics. He is passionate about web technology, measurement, and analysis. Dan is the winner of the 1999 Forge Road Elementary School Science Fair for his groundbreaking report on how magnets work. (ICP, take note.) Dan has worked at LunaMetrics in social media, as our marketing manager, and now in our analytics department.

  • Ian Feavearyear

    For subdomain tracking, do you still enter the cookieDomain field in the Fields to set list but just leave the Value field empty, or do you just ignore it completely?

    • Dan Wilkerson

      Hi Ian,

      Leave it completely empty; don’t select that Field To Set at all, and do not set a value. Let GTM do the hard work for you.

      Dan

    • Dan Wilkerson

      Hi Ian,

      I’ve just discovered I was incorrect about this. You *do* need to set the cookieDomain field to ‘auto’, as it turns out; FWIW, I’m not alone in my surprise.

      Dan

      • Ian Feavearyear

        Thanks, I had wondered as the new GTM course in the Analytics Academy sets it to “auto” by assigning “auto” to a variable and then using that variable

        • Dan Wilkerson

          Yep, that’s how it’s done. Weirdly, it will inherit the existing client ID and store it if you fire an event after setting a Client ID on the hostname, but pageviews create a new Client ID.

  • Maggie

    Hi Dan, how to add the GA cookie when my link looks like this and it’s not in the tag:

    • Dan Wilkerson

      Hi Maggie,

      That’s a good one! In that case, you’ll need to do some custom development. Inside the code for checktout(), you’ll need to add something that retrieves the Linker Parameters and prepends them to the URL that checkout() sends the user to. These are available through tracker.get(‘linkerParam’). You can access your tracker through the ga.getAll() or ga.getByName() methods.

      I hope this gets you started in the right direction!

      Dan

      • http://www.ganotes.com/ Maggie

        Great, thanks!

      • Mark Harnett

        Is this the same method I need to use to get tracking parameters on to this link:

        REGISTER

        Which targets a new window. (and it is not passing the parameters correctly today)

  • Chris Weaver

    Hi Dan, Thanks for updating this for GTMv2 but am still having issues. I got the cross domain tracking to work before, but when adding a new domain I can’t get Tag Manager to recognize it. The ga code isn’t appended to the new URLs, and even the preview trough doesn’t show during preview mode. I added added the new domain to the {{Auto Link Domains}} variable and followed your other steps. Any ideas on why this would occur?

    • Dan Wilkerson

      Hi Chris,

      There’s a bunch of reasons why this could happen; it’s hard to diagnose without seeing the actual code. Offhand, I would guess that the link is opened via JavaScript or a redirect is in place that strips the linker params. If you’ve got a link you can share, I can take a peek.

      Dan

      • Chris Weaver

        Sure!
        StandAZ.com -> TheCignal.com -> CounterStrikeAZ.com are all working fine using this advice.
        The new site is ItMattersArizona.org which is not connecting. The other three are wordpress sites while the new is a bolt-on which I believe might be part of the issue

        • Chris Weaver

          The problem was solved. The coder somehow missed two backslashes in the snippet (not sure how) that were missing on the added page. Lesson being always quadruple check the code first!

          • Dan Wilkerson

            Hi Chris,

            That’s super strange. Glad to hear you’ve got it sorted!

            Dan

  • Brian

    Great post, Dan. How about when there is a subdomain on-top of another subdomain (if that’s what you call it)? I’m currently working with multiple subdomains with the same GA tracking ID and GTM container and confused to what I need to do in GTM ensure a visitor to any of these sites are counted as a single user.

    For example, we manage only the subdomain portion of our companies website (abc.school.edu). Is there anything I need to do in GTM to ensure a visitor to any of these pages is counted as a single user? We want to count someone who visits abc.school.edu,site1.abc.school.edu, site2.abc.school.edu and site3.abc.school.eduas the same user.

    Thank you,
    Brian

    • Dan Wilkerson

      Hi Brian,

      As long as you use the ‘auto’ parameter, you *should* be all set. You can test it pretty easily using an extension like EditThisCookie or the GA Debug tool.

      Dan

  • http://knownonline.com Ariel Matias Bortz

    Hi Dan, great post.
    One question: I’ve tested what you explained, all the “a href” link work perfectly, clicking on them takes me to a website with those _ga extra parameters.

    The problem is with forms: when you have something like

    [a href=”javascript:;”]BLABLA[/a]

    (replace [] for )

    the extra parameters don’t appear, so I suppose the crossdomain isn’t working properly.
    What do you reccommend to do?

    • Dan Wilkerson

      Hi Ariel,

      Try changing the Decorate Forms field in the GA Pageview configuration to ‘True’. That should decorate any forms that are POST’d. If that doesn’t work, you might have to add some custom code to retrieve the parameters and append them dynamically. GA makes them available through tracker.get(‘linkerParam’). You can access your tracker by using ga.getAll() or ga.getByName(). Hope this helps!

      Dan

      • http://knownonline.com Ariel Matias Bortz

        The ‘Decorate forms’ field does the trick.
        Thanks!

  • http://gravitalanalytics.com Stephen Parker

    Thanks for the post, Dan!

    I wanted to point out an alternative way to do this that will eliminate the need to add the domains to the referral exclusion list.

    This method also eliminates the need to decorate the URLs with hash parameters.

    It involves creating two constant variables to apply to your Pageview tag.

    Here are step-by-step instructions.

    First, create two simple variables:

    1. In GTM, click Variables

    2. Select a ‘New’ variable

    3. Name the variable gaDomain and select the type as Constant

    4. In the Configure Variable step, type in ‘auto’ so it will always set the cookie at the highest-level domain and click Create Variable

    5. Create a second new variable named ‘gaCrossDomains’ with a type of Constant

    6. Add the domain names in the Configure Variable field separated by a comma (ex: domain1.com, domain2.com)

    Next, add the variables to your Pageview tag:

    7. In GTM, click Tags, then select your Pageview tag

    8. Click the edit icon in the Configure Tag step, then click ‘More settings’, then click ‘Fields to Set’, then click ‘+Add field’

    9. In the ‘Field Name’ field, click the selector and choose ‘cookieDomain’

    10. In the ‘Value Name’ field, click the selector and choose ‘gaDomain’

    11. Next, go down in the list and select ‘Cross Domain Tracking’

    12. Click the selector for ‘Auto Link Domains’ and select the gaCrossDomains variable was created earlier

    NOTE: Leave ‘Use Hash as Delimiter’ and ‘Decorate Forms’ as false as we do not want to change values across domains

    13. Click Continue and Save Tag

    Once published, you should be able to see real-time metrics from each domain you’re tracking in GA (Real-time Analytics)

    Oh, and this method works for two separate domains as well as subdomains.

    I hope this helps.

    • Dan Wilkerson

      Hi Stephen,

      Thanks for contributing! I think you might have been a little misled by the Real Time Reports; the configuration you’re describing is not cross-domain tracking, and will not work if the end goal is to track users on multiple domains as a single user.

      If you put the same UA on Site A and Site B, you’ll see traffic appear from both domains in the Real Time Report. However, without appending and consuming the Linker Params, if I’m user 1234, I travel to Site A through Organic Search, then I navigate through an internal link to Site B, I’ll appear as two users in the data, one referred from Organic Search and one referred from Site A. Your method appends the Linker parameters, but does not consume them.

      If that is how you wish to model your data, so be it, but that is not truly cross-domain tracking, that is simply tracking multiple domains in a single property. Adding the Auto Link Domains field is unnecessary if this is the case.

      Finally, you’re taking an unnecessary step by adding the cookieDomain Field To Set. The default configuration will use ‘auto’, so you do not need to set that value at all.

      Dan

      • Dan Wilkerson

        Hi Stephen,

        Turns out, I was incorrect about ‘auto’ being the default behavior. You *do* have to set the cookieDomain field to track across subdomains. That said, the rest of my comment is still true.

        Dan

        • http://gravitalanalytics.com Stephen Parker

          Aha, yes, I was quick to scan the post, and now realize that you’re focusing on user tracking. OK, that makes more sense now. Thanks so much for the post and the feedback Dan! Cheers!

      • Valery11

        Hi Dan!

        I have done all the settings you recommended including Auto Link Domains but still I do see the user from both domains in the Real Time Report after he gets to the other domain by clicking.
        I am pretty sure the implementation is correct since I have done it before. Would you have an idea about where the problem could be?

        Thank you very much 🙂

  • Mahfuz Rahman

    Hi Dan. Thanks for a great post.

    I was trying to implement a cross-domain tracking with an iframe content following this article here “Google Analytics cross-domain tracking with Google Tag Manager – Part 3: Iframes” at http://www.knewledge.com/en/blog/2013/11/cross-domain-tracking-for-iframes-with-gtm/

    This requires establishing the cross-domain linking first and the custom code decorates the iframe URL.

    As I will be using GTM V2, should I follow your steps for the domain GTM settings for the container only?

    And then I can try to implement the custom code given in that article to decorate the iframe URL, right?

    Your suggestion and direction regarding this will be much appreciated.

    Thanks.

    • Dan Wilkerson

      Hi Mahfuz,

      You’ll still want to follow all of the above steps; allowLinker will detect the linker params in your iframes src attribute and pull them in, but you’ll want to configure GTM to autotag any cross-domain links just in case (and there should be no harm in doing so, even if there are none).

      Dan

  • Tiaan Van Zyl

    Hi Dan,

    Awesome article!

    Quick question on a redirect. When a user clicks on a link to our desktop site (www.domain.com) with a mobile, they automatically get redirected to the mobile site (www.domain.mobi). Will I need to implement cross-domain tracking in the case?

    Thank you,
    Tiaan

    • Dan Wilkerson

      Yes, otherwise they’ll have a new cookie on the .mobi site.

      Dan

  • Katie K

    Hi Dan –

    Great article. Are these steps the same for cross-domain tracking 2 domains that are using different GTM containers (website & shopping cart)?

    Thanks!
    Katie

    • Dan Wilkerson

      Yes, you need to do this to your page view tracker in each container.

      Dan

  • Laurens Aertssen

    Hi Dan, I need to track iframes whose source are subdomains. In other words I have a page on the main domain website, where there is an iframe to a subdomain.

    I followed your recommendation and enabled cookieDomain=auto. I can see that the clientId is the same accross all subdmains, but still some questions remain:

    1)How do I prevent that my main domain becomes the referrer to the subdomain? I added to referrel exclusion, but debug still shows it as referrer.

    2)I don’t want the subdomain to send a pageview, however I do want to track events in there. Do I simply create an event tag for the subdomain page url with the cookieDomain=auto ?

    Thanks in advance!

    • Dan Wilkerson

      Hi Laurens,

      Ideally, you should use the postMessage API in order to accomplish this; there’s little reason to load in GTM in these iframes (and Google Analytics, and all of the cookie logistics and sessionization issues) if all you need to do is note when users take particular activities.

      https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

      If that’s absolutely not an option, let me know.

      Dan

      • Laurens Aertssen

        Hi Dan,
        Thanks for the quick reply. The reason we implemented GTM is to have the flexibility to not have to rely on the IT department. This way I can easily track all the events.
        That postMessage solution you propose looks good, but if I am correct it would require us to implement code for each event we want to track?
        With the current setup the only blocking issue is that we have self-referrals. Is there any way to solve that through tag manager?

        Thank you!
        Laurens

        • Dan Wilkerson

          Hi Laurens,

          More or less; you could configure a standard handler that would watch for all events of a specific type and emit them out, like submissions or clicks. But I understand the desire to avoid having to go this route.

          Your alternative is to add a blocking rule to the pageview tag that detects if a page is in an iframe. A Custom JavaScript Variable with return (window.self !== window.top) ;should be a sufficient test for this. You can then emit events from there safely, and as long as the cookie is the same on both the domain of the parent frame and iframe you’re all set.

          Per the referrer question, if you’re talking about the value in GTM, this is simply the JavaScript value document.referrer, not the Source / Medium or session information GA will assign that hit (although the referrer is used to determine this information when the session first starts).

          Hope this answers your questions!

          Dan

  • Terral

    Hey Dan, I am currently trying to implement cross-domain tracking for a website and a hotel reservation system (https://synxis.com). Initially, I followed the instructions by Google Academy which another user, Stephen Parker, commented on. After reading your comment to his suggestion, I am going to make the changes to my tags and variables to match this article. Thanks for all the great information so far! However, I do have one more quick question:

    Once I have all my variables set up and tags updated, do I need to send the GTM code snippet to the reservation system to inject into their site for our hotel or is one GTM code injection into my hotel’s site sufficient?

    • Dan Wilkerson

      Hi Terral,

      1. I’m not sure I understand your question 100%, but it sounds like your asking if you have to keep updating the GTM snippet. Once you’ve got the snippet on your site, you’re set; you do not have to send it each time you make changes, just ‘Publish’ and the changes will be live.

      2. You should set up a gaDomain variable to be consistent and to simplify changes, if necessary. Add this to every Google Analytics tag.

      Dan

  • Gimmy

    Hi Dan,

    I’ve implemented cross domain tracking code through Google Tag Manager. I’ve got a form so I’ve set all necessary tags (pageview and decorate form).

    The problem is that it only works perfectly if we use Firefox, while using Chrome, Safari and IE, there’s something wrong. Traffic sources for conversions are shown only as Direct (using Chrome ect..).

    The only difference I’ve noticed is the linker parameter in the url.

    Using Firefox it looks like this

    _ga=1.185056879.773010676.1440490793

    while using Chrome it looks like this:
    _ga=GA1.2.997177453.1433838012
    As you can see, it adds a GA before the linker parameter.

    I’m wondering if this difference is causing the problem. If so, do you have any idea about how to solve it???

    Many many thanks in advance.

    • Dan Wilkerson

      Can you share a demo page I can test this on? The second example is the GA cookie, not the Linker Param. That’s what shows up in the URL? Is there any other code on the page that may be setting this value, from an old implementation perhaps?

      Dan

  • Namrata Srivastava

    Hi Dan,

    I am trying to implement cross domain tracking on form post using GTM.

    My form action is like

    this redirect me to a blank page first which has the current domain and on that blank page the main form code is written which redirect me to the cross domain.

    I have tried to get this done using form decorator and Auto link both none of them working. I think it’s not able to pick the corss domain URL since it is on redirected page.

    Please suggest any solution.

    • Dan Wilkerson

      Hi Namrata,

      Yes, you are correct. Your options are limited; you need to add code on the blank page that the user is redirected to to either append the linker params to the URL they are redirected to manually (you can access them by using tracker.get(‘linkerParam’); ) or by sniffing the _ga cookie and appending the client ID from there with your own system.

      Dan

      • Namrata Srivastava

        Hi Dan,

        Thanks for your response.
        I have one more question… In the trigger, Configure trigger section i have unchecked both Wait for Tags and Check Validation. In that case I can see some utm parameters are getting appended to my destination URL.
        But that parameter value are not same as UTM query string parameter. Can you please let me know what kind of behavior is this? I this correct?

        Thanks in advance.

        Regards,
        Namrata

  • Asgaut Mjølne

    Hi,

    I need to implement cross domain tracking to be able to track visitors that goes through an external credit card terminal (external domain). The vendor of the terminal supports receiving and sending back additional parameters.

    Which parameters and values should I send to the terminal, which again will be sent back after a confirmed payment?
    Guess its _ga=1.1123….. ?

    And how do I get hold of the parameters? Since I am using Google Tag Manager, I was not able to get hold of values like explained here https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain.

    Note that this is not a form I can decorate, its a HTTP client that posts values behind the scenes.

    • Dan Wilkerson

      Hi Asgaut,

      So to be clear, your users come to your site, load up a cart, and go off to a third party to purchase and then are redirected back to your site upon purchase completion?

      Dan

  • http://www.tennisonline.fr TOteam

    Hello Dan.

    I have a question for you.

    I want to track a domain and a subdomain

    pizzadelight.com

    order.pizzadelight.com

    For the moment they had two separate Google Analytics UA-1 et UA-2

    I want to install GTM.

    I have followed your post and i was wondering what i need to install in both websites

    1- First website Pizzadelight.com

    I need to copy this code

    <!–Implement the following part right before the closing tag–>

    var host = window.location.hostname.split(‘.’);
    dataLayer = [{
    ‘Hostname’ : document.location.hostname,
    ‘GA-hostname’ : host[host.length-2]+’.’+host[host.length-1],
    ‘GA-UA’ : ‘UA-31720680-1’,
    ‘currentURI’ : document.location.pathname+document.location.search,
    }];

    and copy the code of the Snippet.

    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
    ‘//www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,’script’,’dataLayer’,’GTM-KM7JZ7′);

    Questions :
    What do i need to do with ‘GA-UA’ : ‘UA-31720680-1’, ?
    Do i need to add in there the UA of the second website

    Or do i need to create a new property using the same UA ?

    2- Second website Order.pizzadelight.com

    What code do i need to place, the same Snippet and the same Data Layer ?

    Thanks in advance for your help

    Raphael

    • FabCom

      1. Remove all tracking code from both sites
      2. Install single GTM container on all pages of all domains immediately following the opening tag
      3. Create a single GA Pageview tag
      4. Refer to Dan’s section before Step #1 and follow his instructions.
      5. Publish GTM

      • http://www.tennisonline.fr TOteam

        Thanks FabCom.
        Question : On order.pizzadelight.com do i need to place the GTM Snippet and Data Layer as well ?

        • http://www.fabcomlive.com FabCom

          You don’t need to place anything except GTM.

          • http://www.tennisonline.fr TOteam

            You mean the Snippet

            (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
            new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
            j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
            ‘//www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f);
            })(window,document,’script’,’dataLayer’,’GTM-XXXXXX7′);

          • http://www.fabcomlive.com FabCom

            Exactly. Make absolutely certain it is pasted immediately following the opening tag on all pages you want to track.

            The GTM “snippet” is also referred to as the GTM “Container.”

          • http://www.tennisonline.fr TOteam

            Ok so Data layer code on this page…
            And remove the old GA from order.pizzadelight.com

          • http://www.fabcomlive.com FabCom

            You have remarketing tags also on the page which should also be deleted and then replaced by an AdWords Remarketing tag created in GTM instead. From what I can see, you don’t need the datalayer for any reason if you’re firing all your tags from GTM.

          • http://www.tennisonline.fr TOteam

            Thanks a lot FabCom

            To sum up :

            On Pizza Delight

            1. Remove all tracking code
            2. Install single GTM container on all pages of all domains immediately following the opening tag
            3. Create a single GA Pageview tag
            4. Refer to Dan’s section before Step #1 and follow his instructions.
            5. Create Adwords Remarketing tags to replace old remarketing tags

            6. Publish GTM

            On Order.pizza.delight

            1. Remove all tracking code
            2. Install single GTM container immediately following the opening tag

            Is that correct ?

          • http://www.fabcomlive.com FabCom

            Spot-on. Remember for ease and simplicity for your particular situation, use the same GTM container that contains the same GA property that fires on “all pages”

  • Ruud seydel

    Super nice clear post. Thanks!

    • Dan Wilkerson

      No problem; glad it helped!

  • Jorge

    I have a different problem which is related to this somehow. I have one parent domain, which calls an iframe in a different child domain. I have a google tag in both domains to track usage effectively. But now I have a duplicated tag message on the tag assistant. Any suggestion on how to solve this? Am i suppose to put different tags on each domain or how do I manage this?
    My parent domain: http://guruexperiences.com/en/activities-adventure-tenerife-2/bike-and-mountain-bike/mountainbike.html
    Calls the child domain via an iframe here:
    https://guruexperiences-portal.booc.opencanarias.com/

    Thanks in advance, Jorge

    • Dan Wilkerson

      Hi Jorge,

      You’ve got to figure out a way to transfer that Client ID into that iframe. There’s a few ways you can do this:
      – Append it to the iframes src attribute, which can work if you insert the iframe into the DOM dynamically, just call ga.getAll()[0].get(‘linkerParam’); and set up the other cross domain stuff as per usual
      – Use the postMessage API to transmit the Client ID into the child frame after they’ve both loaded. I’m writing a post about this currently, so keep an eye out

      Hope this helps!

      Dan

  • Jeff Molitor

    Dan, outstanding post and very helpful. i followed all of the directions, enabled the debug mode and everything looks fine. but when i add an adwords conversion (via gtm) that fires on one of the cross domains and test in GA real-time under conversions i dont see it flowing through at all. in preview mode for gtm the tag fires. any idea why? thanks

    • Dan Wilkerson

      A co-worker requested I respond in rhyme:

      Jeff, here’s the thing /
      Your data’s not missing /
      It’s simply got /
      A different spot /
      AdWords reports are just the thing

      You see that pixels not /
      The one that GA got /
      The data that it girds /
      Only shows up in AdWords /
      That’s why your hit’s missing

      I’d suggest using a GA Event /
      In order for you to prevent /
      Your reporting frustration /
      Or a sanity vacation /
      Then you’ll get your reporting

      – A Limerick for Jeff

      But seriously, the AdWords conversion tag type sends data directly to AdWords, not Google Analytics. If you want to view that data, you’ll either need to go to the AdWords reporting interface, or you’ll want to set up a Google Analytics Event, create an Event Goal, and then use Goal Importing to get your data into AdWords and GA.

      Dan

      • Jeff Molitor

        haha – i wish i was 1/10 as funny when discussing gtm. great feedback and makes total sense. you are a kind and knowledgable person and soe day people will write songs about you. thanks!

  • Brian

    Hi Dan, thank you for the very helpful post! One question I have is regarding the auto domain list. Is there any harm in including multiple subdomains of the same top level domain in the list if the cookie domain is auto? I know the auto setting covers those but we have those all over the place, sometimes outside of GTM unfortunately, so would love to include the same list everywhere and wondering if that has any negative impact. Thanks,

    • Dan Wilkerson

      Hi Brian,

      Tested this quickly and it works fine!

      Dan

      • Brian

        Thank you so much!

  • Yannis

    Hi Dan you’re awesome!

    I’m trying to implement cross domain on a page that has a javascript redirect and I can’t seem to make it work.

    2 questions:

    1. From what I understand I need to append ?_ga=1.259232963.111111111.1426674415 to the redirect url?

    2. To get the linker parameter I’m supposed to get through the following function:

    ga(function(tracker) {
    var linkerParam = tracker.get(‘linkerParam’);
    console.log(linkerParam);
    });

    However ga() is undefined when running analyitcs through GTM. How do I get access to ga()?

    • Dan Wilkerson

      Hi Yannis,

      Welcome to the wild and wonderful world of asynchronous-ity. ga() will be defined, as long as you’re firing a Google Analytics tag, you just need to wait until after a tag has fired. A good way to ensure this is to either use Tag Sequencing or to use the hitCallback Field to Set. I would recommend doing this:

      1.) Create a Custom HTML tag and paste the stock GA snippet into it
      2.) Remove the ga(‘send’, ‘pageview’) line from the stock snippet
      3.) Add the code you need to extract the linkerParam and append it to the redirection URL.

      Please note – this only is going to work if you’re client-side redirection occurs on the same domain as the page previous to the redirection. You’ll also want to ensure the domain with the redirection is on your Referral Exclusion list.

      Dan

  • Bromdog Brom

    Dear Dan,

    Thanks for your great tutorial.

    The tutorial states the CookieDomain should be set to “Auto” in case only subdomains are used. What should I do when some domains are subdomains and some are not? For example consider the following list of domains: site.com, a.site.com, b.site.com, c.site.com and sitenew.com. I assume the CookieDomain = Auto can be left unchanged, am I right?

    Thanks and keep on going!

    • Dan Wilkerson

      Hi Bromdog,

      You’ll set cookieDomain to Auto and you’ll but sitenew.com,site.com in your Auto Link Domains Variable.

      Dan

  • http://www.marketingnerds.com/ Gilbert

    “Before you get started… If you are trying to track users across many different subsections of a single domain…”

    I can’t tell you have many times this blog has saved my ass. Just wanted to say thanks!

    • Dan Wilkerson

      Glad to hear it, Gilbert.

      Dan

  • Roy Smid

    Hi Dan,

    Thnx for this great article!

    Trying to get cross domain tracking set-up with GTM en Universal Analytics. We have a third party form (SharpSpring.com) embedded on our proposition pages which is causing a redirect and so sets a new referrer on app-1dw038y.sharpspring.com. For example https://www.youwe.nl/google-adwords-specialist/.

    Followed the above instructions but it won’t work for me. Any ideas our suggestions here?

    See screenshot for setup.

    Thnx for your feedback.

  • Nidhi

    Hi Dan,

    Thank you for the best post on GTM cross domain tracking ever.

    I am stuck in a scenario that’s a bit tricky. SO i’ve got site a,b and c for cross domain tracking. the user can go from a-b-c or a-b or a-c. Now a to b and a to c is getting tracked correctly with the ga parameter appended at the end of the URL but when I go from b to c the ga cross domain tracking parameters disappear. b does send extra user info parameters to c, and after landing on c it does go through a redirection but its from a subdomain of c. I’ve setup all the container settings and exclusions as described by you.

    When I do an inspect element of the link that takes the user to c, I can see the ga parameter added at end in href but it just disappears after clicking the link. Please help.

    b=https://test.mysubcalc.net/Results.aspx?ID=6e9f1836-c113-4783-8a6a-dfd4abdac3e0
    c=https://horizon-uat.gohealth.com/marketplace/#/questionnaire/cc082f22ec104ddea5d216e7c9f8a38d

    • Dan Wilkerson

      Hi Nidhi,

      That sounds like your webserver is not preserving the _ga parameter upon redirection. You’ll need to adjust the redirection engine within your webserver to preserve that _ga parameter on any redirection in order to fix this. You could try using the fragment, which is one of the checkbox options (I believe it’s something like Use Fragment) in the Cross Domain Tracking section, but that’s unlikely to work. You could also try using the Decorate Forms option in case this is actually a form submission-style redirection, but that’s also probably not going to fix it.

      On a side note, to track between different subdomains, you just need to set cookieDomain to ‘auto’.

      Hope this helps!

      Dan

  • Alexander

    Hi Dan,
    Really like your posts – you provide valuable insights! So thanks for that!

    My question may have been answered below but I’ll still throw it out there: I recently split one domain, http://www.beauty-shots.de (which had previously been one website for two businesses in two different cities), into three different domains: http://www.beauty-shots.de, http://www.beautyshots-berlin.de, and http://www.beautyshots-hamburg.de. The original “main domain” now has been transformed to a fairly simple landing page which links out to the other two sites. I control both the main domain and the new Hamburg site, and have implemented GTM on both, continuing the analytics for the main domain and adding a new analytics property for the new site. So obviously what is now happening is that most people are landing on the main URL and then clicking through to the new site, which means the main site is showing as the referral path. Since I have control over both I would like to “pass” the source/medium and any other relevant information about visitors from the main site to the new site and in the best case completely eliminate the main landing page site as a referrer from my Hamburg property reports. What would be the best way to do that while still keeping both analytics properties separate?

    Looking forward to your answer!

    • Dan Wilkerson

      Hi Alexander,

      In order to preserve originating source/medium information, you need to send hits with the same Client ID to the same UA number; since you’ve got two different properties, you can’t really do this.

      I think the easiest option would be to create a Rollup property that you deploy to both sites, with cross-domain tracking setup and the referral exclusion list populated for each. Then, create views with hostname filters for each domain. That will give you the originating source/medium with data scoped to each domain.

      Dan

  • Michael Wilson

    Dan,

    Thanks for the great post. I do, however, have a specific question for you regarding sub-domain tracking. I’m trying to track visits throughout my companies marketing site (marketing.exampleapp.com) as well as the setup wizard pages once they cross over to exampleapp.com. I’m not interested in tracking all the page hits on exampleapp.com as there are thousand a day.

    I have google analytics set up for both the domain and subdomain but I was wondering if I should create a specific view in GA and use a regex to include all traffic from marketing.exampleapp.com, and just the 3 pages (the setup wizard) from exampleapp.com.

    So, after all that, my question is how would I create that regex to include all the subdomain traffic and only a tiny fraction of the main domain traffic; and, would I set that up with the cookieDomain set to ‘auto’ once I have that particular view in place?

    Thanks again,
    Michael

    • Dan Wilkerson

      Hi Michael,

      Can you add GTM/GA to just the wizard pages? Will other traffic hit those pages (not from your marketing site)? If no other traffic can get there, do that.

      You can also filter the hits on the client side using either a query parameter or sniffing the referrer. Basically, in GTM, add an exception that blocks your tags from firing if the referrer doesn’t contain marketing.exampleapp.com, then cookie the user as OK and fire hits moving forward.

      Finally, you could just use filters that exclude sessions not referred from your marketing site and that only include those pages. However, you’ll lose the ability to tie acquisition information to your goal conversions, as all traffic that visits those wizard pages will appear as referred from your marketing site, instead of how they got to the marketing site in the first place.

      Dan

  • DeviousMrBlonde

    Hi Dan,

    I’m only dipping my toes into this world so please excuse my fresh faced innocence.

    I have an embedded shop for selling tickets to an event.
    http://www.onlinemarketingrockstars.de/expo/2016/ticket-kaufen/

    The Linker is being created but I’m not getting any tracking info back from the amiando.com side.
    https://www.dropbox.com/s/t8tslicjdmf9eie/Screenshot%202015-11-17%2014.34.07.png?dl=0

    The iframe URL doesn’t have the GA Client ID attached to it, so I’m guessing something is not matching up there.
    https://www.dropbox.com/s/pvdw62o8bffpbgw/Screenshot%202015-11-17%2014.38.56.png?dl=0

    Maybe my case doesn’t even match the requirements of what you’re describing. As, I said, just getting going in this world and it’s very daunting.

    Thanks for any help.
    Ed

    • Dan Wilkerson

      Hello,

      Do you have GTM/GA on the amiando.com side? If not, can you add it? If you can’t, you cannot do cross domain tracking.

      Dan

  • Andrey

    Thank you for the post. Can you briefly review the use case when we need to set up cross domain tracking for 5000 websites? Is it possible to update the list of websites automatically?

    • Dan Wilkerson

      Hi Andrey,

      Then you’ve got to be clever. A simple hack to do this is to generate linker params, then store them with your own custom query parameter on the query string, then sniff for those in each container. You’ll need a custom script tag that does all this and binds to mousedown/keydown/touchstart.

      Dan

  • http://automatedmarketinggroup.com Kurt Henninger

    This may seem like a basic question here, but I’m assuming that you publish the same GTM container on ALL domains, not a seperate container for each domain, correct?

    I’ve read other methods to implement cross domain tracking which require a separate GTM container for each website along with separate Analytics properties.

    Thanks for the clarification!

    • Dan Wilkerson

      Hi Kurt,

      It’s not required to use the same GTM container; I generally prefer a separate container for each hostname, unless the different hostnames are essentially white-labeled or our needs are very simple. Just set up identical Cross Domain configs in every container you use, send the data to the same Property, and you’re all set.

      Dan

      • http://automatedmarketinggroup.com Kurt Henninger

        Thanks!

  • Joe Polite Jr.

    I need urgent help. I run a credit card comparison website. We send prospects to banks’ online applications where the conversion happens. People get either an “approval”, “rejection” or “more analysis needed” thank you page once they finish the application. In the past, we could only keep track the funnel steps up to the point where the prospect clicked the “Apply Button” and leave our website, however, now the bank is open to place a “Conversion Pixel” in their thank you pages so we have more information. What would be the simplest way to implement this using GTM? Is it even possible? I would welcome any help!!!

  • Graeme DB

    Hey Dan, great article! I just want to confirm that for this to work I’ll need to be tracking the domains in the same GA account, as I’m not currently and would prefer not to if at all possible. If I need to do so, would it be best to just set up filters to look at how each domain is performing separately? Thanks!

  • Steven Green

    Hi Guys. Thanks for the amazing read here. Need some assistance, we’re doing cross sub-domain tracking. Each sub domain has it’s own property within the same analytic account. so the trailing -xx changes for each sub domain. We’ve setup the same tag manager code on all the sub domains as well. The issue im having is when i click from subdomain1 to subdomain2 I cant see the original source of traffic. I need to be able to see “Organic & Paid & Referral”. Right now I get direct & if I try and exclude the domain I get referral. However I need more information that than. Any ideas?

    • Dan Wilkerson

      Hi Stephen,

      If you want to preserve original referring information across your properties, you’ve got two options: you can create a mechanism to capture, store, and transfer the HTTP referrer, UTM parameters, and the gclid/dclid, or you can set up hostname or Custom Dimension Filtered Views and track everything in one property.

      If you’re using Google Analytics Premium, you can take advantage of the Rollup Reporting feature instead: https://support.google.com/analytics/answer/6096167?hl=en

      Dan

  • http://www.shopperlocal.com/ Khem Raj

    Hey! Thanks so much a great article. But what should we do if our sub-domains are being generated dynamically. I want to track traffic to our web app and each of the client will have the sub-domain of his own choice.

    E.g. client1.example.com, client2.example.com, client3.example.com and so on. We may even have more than 10,000 such clients in next 30-40 days. Now I want to track each sub-domain individually. Can you please shed some light on this?

    and I also want to check which sub-domain as maximum traffic, so I need to see the sub-domain name as well

    • http://www.shopperlocal.com/ Khem Raj

      Hey @disqus_ZlOkX51Bk6:disqus

      Can I please expect some response to my query. Thanks!

      • Dan Wilkerson

        Hi Khem,

        If you’ve got dynamic subdomains that you’d like to track in the same account, you can just deploy the same container with the same basic tags to each of those. If you want to track users across each of those subdomains, you can set the cookieDomain value to ‘auto’, which will result in the same client ID being used on each subdomain. If you want to track users in the same account but in exclusion of one another in terms of each subdomain, you’ll want to leave that setting alone. If you want to track across multiple domains (not just subdomains, whole different domains), you’ll need to implement the above. If you’ve got a dynamic range of domains, I’d suggest creating a new query parameter specific to your sites and appending that parameter to all URLs, then decoding it within the same container.

        It sounds like cross-domain tracking might not be exactly what you’re looking for – I’d need to know more about your particular situation in order to really make a recommendation. Since your situation is so complex, I don’t know that I’ll be able to help very much in this format. I’d encourage you to drop us a line about a potential consultation contract, though, at getinfo@lunametrics.com.

        • http://www.shopperlocal.com/ Khem Raj

          Thanks @disqus_ZlOkX51Bk6:disqus
          Actually, we’ve have three profile views – 1. Whole website (default), 2. Main domain only (mywebsite.com – without “www”), 3. Sub-domains only.

          I’ve been facing problem with 3rd one, where I want to track all dynamically generated sub-domains in single profile view, but I would definitely want to see which sub-domain is getting more traffic and which is getting least traffic (so I want to see the full URLs of all pages in reports)

          Then we’ve few filters as well.
          1st – My domain runs without “www” and we’ve a few test sub-domains as well which is again huge in numbers, like test1, test2, dev1, dev2, demo1, demo2 and so on. But these are only 4 – stage, test, dev and demo. We definitely would not like to include traffic to test domain in any of the view. what can be the regex for this as it not possible to filter the test sub-domains manually due to huge numbers.

          2nd – filter traffic to main domain in sub-domains only view

          Yeah, I’ll definitely send you an email with more details. Thanks again.

  • Polka Princess

    Is it possible to use GTM to track across seperate domains where the domains have different GA properties?

    • Dan Wilkerson

      Hi Polka Princess,

      You can, but I wouldn’t recommend it. With a less complicated setup, this can work alright, but as you add more and more tracking, you’ll run into trouble. I’d recommend a separate container per hostname.

      If you still want to go this route, you’ll just need to use a Lookup Table based on the Page Hostname and return the appropriate GA ID depending on which hostname you’re on. For a guide on how to do this, check out Simo Ahava’s post on Macro Magic – you’ll use the setup described for #10.

      http://www.simoahava.com/analytics/macro-magic-google-tag-manager/

      Dan

      • Rishi

        Being an Analytics expert, you are supposed to respond to every query, I noticed you just respond to the queries which you’re comfortable with. You don’t seem to be an expert. Right below there are a few complex questions, but you’ve conveniently ignored them.

        • Dan Wilkerson

          Hi Rishi,

          I appreciate you trying to keep us honest! I’m not sure which questions you’re referring to; I try to answer questions when I can, and I do sometimes skip more complex questions when I’m in a rush (especially towards the end of the year). Sometimes, urgent questioners will follow up with me on Twitter or email, and I’ll answer there, so my response won’t end up in the comments here. I’m also more than happy to answer a question with “I don’t know”, though 🙂 (in fact, that would be much easier than simply ignoring a tough question!)

          If there’s a particular question you’re referring to, point it out; I’m happy to take a look now.

          Dan

  • Gagan Batra

    Hi Dan, thanks for writing this article.

    We are getting this error in Developers Console, which is over riding the clientID of the source domain at the destination domain ‘New visitor. Generating new clientId’ This only happens for the first time visitors but if we go back to the destination domain from the source domain – Developers console is easily able to load link parameter as per your testing guide #5.

    Why would this happen? Thanks heaps

    • Dan Wilkerson

      Hello Gagan,

      Are you traveling to the destination domain via a link on the source domain, or merely loading the destination domain in a separate tab?

      • Gagan Batra

        Hi Dan, I am clicking on a link (CTA) on the source domain to go the destination domain. For a moment, i can see the ?_ga parameter appended on the source domain but then it disappears.

        • Dan Wilkerson

          Is there a redirection? If you share a link to the source domain and tell me where to find the link to the destination domain I’ll take a peek.

          Dan

  • antosusc

    Hi Dan,
    how would you solve a “wordpress.com” or “tumblr.com” situation? Where we generate automatically webpages that are available in our customer domains. We would like to have an overview of everything and dont care so much if there are referral reporting problems. I think we cannot add 1,000 domains as suggest in step 1
    Thanks!

  • Olivia

    Hi Dan,

    Thanks so much for the article 🙂

    I have a question that is related to this topic but instead of subdomains, they are actually two different domains.

    So for example, you are currently browsing on domainA.com and then upon clicking a button, it opens a new tab on your window and redirects you to domainB.com (which is the booking engine). If we are using the same GTM on both domains, how would you ensure that the referral information get pass along correctly?

    Thank you!

    • Dan Wilkerson

      Hi Olivia,

      You’re in the right place! The above is what you want to implement – fill in the Auto Link Domains field and check Allow Linker.

      Dan

      • Olivia

        Yes, I misread the initial part and I thought this is to track subdomains. Apologies for that. Thanks for the reply. Will let you know once I’ve tried this method.

        Many thanks Dan. Have a great week ahead!

      • Olivia

        Hey Dan, I have filled in the auto link domains and also check the allow linker. I tested this method using the preview mode but I could not see the loaded linker parameter in console and there was not extra parameters on the URL as well. Do you know why this happened? thanks a lot!

        • Dan Wilkerson

          Hi Olivia,

          Did you try clicking on a link between your domains? You should see the ?_ga parameter appear in the URL on the destination domain.

          Dan

          • Olivia

            Yes i did. I clicked on a “book now” button on the first domain that will bring me to the second domain, however, the website is built in a way such that whenever we click on the ‘book now’ button, it will open up the second domain on a new tab : I check the cid parameter after I opened the developers tool on the 2nd tab (and refreshed the page because initially the collect information was not available) and the cid value is different from the 1st domain.

            The second domain is actually a booking engine – Synxis and i heard many people have issues with this booking engine.

            Thanks Dan.

  • D. Mancini

    Thanks for the article Dan,

    Would I be able to use this same methodology to decorate the url of an iframe form (hosted by a subdomain) embedded within my contact page?

    The service I am using for form submissions only passes GA data into its CRM database if the URL hosting the form has UTM parameters. Can I use your methodology above to populate UTM parameters mid-session to that iframe URL?

    • Dan Wilkerson

      Hello,

      This isn’t going to cut the mustard, in that case. If you’re using Classic Analytics, and your iframe is on a subdomain, you could try checking the UTMZ cookie, since it will contain your source/medium and be available on the subdomain. Otherwise you’ll need to write something to parse source/medium out on session start, store that value in a cookie, and then decorate and absorb it in the iframe or use the postMessage API. My series on Iframes might be a good starting point:

      http://www.lunametrics.com/blog/2015/10/21/google-analytics-iframes-form-submissions/

      Dan

  • Patrick Sidney Stewart

    Thanks for your article Dan – I’ve been googling around this topic trying to fix my problem but I keep ending up back here as the most comprehensive discussions on the topic.

    I’ve set up cross domain tracking on Google Tag Manager but I was still seeing self-referrals as my number one referring source. So I’ve added my domains to the referral exclusion list on the property. However I’m concerned that that will not stop the extra sessions being created but merely reassign them as ‘direct’ traffic rather than ‘referral’. And what I presumably want is to have the sessions that are currently marked as self-referrals acknowledged by Google Analytics to be the continuation of previous sessions. Am I wrong to be worried about that?

    I’m a non-profit marketer not a coder so I find a lot of this information confusing. I’ve used a webcrawling tag checking tool to checked that all the pages on the domains have the GTM code installed and I can see in preview mode and using tag assistant that the tags are firing away. I set up the cross domain tagging exactly as per the Google Tag Manger Analytics Academy demo (though there they don’t mention having to add the domains to the referral exclusion list).

    Any advice would be hugely appreciated 🙂

    • Dan Wilkerson

      Hi Patrick!

      A very understandable concern – there’s good news, though; Google Analytics will not start a new when a hit comes in that would be interpreted as Direct (including via the Referral Exclusion List), as long as the user has a currently active session. Once you add your own domain, your self-referred sessions will instead be one continuous, uninterrupted session.

      Thanks for the great idea for a new blog post 🙂

      Dan

      • Patrick Sidney Stewart

        Thanks so much for clearing that up! It’s a huge help. I was scared to take the plunge as you have to do it for the whole property rather than the individual views so you can’t test it :/ Patrick

  • Thangaraj

    Thank you for a great guide, simpler that that of ganalytics’ own guide.
    I’ve been trying this out & while both test #1 & #2 are positive, I’m not able to see the utm params have any effect on the real time google analytic screen. So I’m not sure it is actually working. Is this expected behaviour? Should I wait 24 hours & check the regular analytics reports for the test utm params?

    • Dan Wilkerson

      Hi Thangaraj,

      Can you confirm that you’ve got the parameters spelled exactly as they appear in the blog? Sometimes a typo gets in there and without both keys correctly set, the Realtime Reports will not correctly show you the data.

      If you’re not seeing ANY data in Realtime Analytics, they take a while to spool up in new properties and properties where the Realtime reports haven’t been accessed in awhile. If you do see data, but no source/medium, you might have to dig further.

      Either way, periodically check your Source/Medium report (often the data shows up very quickly) and check if your session appears there.

      Dan

      • Thangaraj

        So this is strange. I’ve double checked everything, still the realtime is showing up with source medium as (none)/(direct). But the standard google analytics data is now showing the correct source medium values (which I tested 4-5 hours back). Not really sure what to make of it.

        • Thangaraj

          Tested it just now & real time also shows up correctly! Just like that 🙂
          Thank you for a wonderful guide & great support. Much appreciated!

          • Dan Wilkerson

            Great! Glad to hear it.

            Dan

  • Michelel

    Could you give the same tutorial but with the Classic Analytics set up in tag manager.

    • Dan Wilkerson

      Hi Michelel,

      First, you’ll need to configure the Allow Linker setting under Domains and Directories in your Pageview tag. Next, create a new Classic tag and from the Type dropdown, select ‘Decorate Link’ and create a trigger that fires when Click Hostname matches the domains you want to track across. Voila!

      Dan

  • Mike M

    Hi Dan, great post! Exactly what I’m looking for to create a roll up property for tracking across all of my related sites.

    I didn’t see it mentioned, but how do we fire 2 separate GA page tracking events from GTM. I want to have a GA property for each individual site and then track 1 roll up property for all sites combined. Thus each site would need 2 GA page tracking scripts.

    I don’t think this can be done by creating 2 GA tags/triggers in GTM because it will include the GA .js library twice. Am I correct in this assumption?

    Much appreciated!

    Mike

    • Dan Wilkerson

      Hi Mike,

      No worries! You won’t wind up requesting analytics.js or ga.js twice. You can safely duplicate your tags.

      Dan

  • Michael J Gale

    This is great info Dan,
    I work in radio and I am hoping to use cross domain tracking to show clients
    conversions from our listeners. Since we know only our listeners come to
    our stations websites we want to show clients how many of these listeners come
    to their sites (in a 20-40day window).
    First, if we have access to a client’s GA can we simply set up a goal to look
    for this cookie from our site? Can you use cross domain tracking
    like this? As in, can we place this tracking code on let’s say http://www.mytalk1071.com and
    then have 10-30 clients GA look for this and track? Or does it only work
    for one to two domains? Thanks for your direction. Would you
    know anyone locally in Minneapolis that could help implement something like
    this?

    • Dan Wilkerson

      Hi Michael,

      They should already be able to see this data in the Acquisition -> Source / Medium reports, as your site should appear as a referrer. If you’d like to bullet-proof it, you could add Campaign Parameters to the end of your links to client sites, which would ensure the source / medium would connect back to you.

      Dan

      • Dirk Leeward

        Thanks for the great post Dan,
        I have a similar question to Michael’s. We’d like to send interaction with advertiser’s inventory ads from our site as Events not just to our UA account, but also to the advertiser’s UA account. I tried copying a tag and changing the UA account number, but I assume Google needs to somehow verify that I have permission to do this. Can this be done?

        • Dan Wilkerson

          Hi Dirk,

          No, Google Analytics doesn’t require any kind of verification. This is how bot spam can appear in your account. Your setup will work just fine.

          Dan

  • davepatrick

    Dan,

    Thanks for the article. I need some help. Here’s the situation,
    Firstly if I want to do cross domain tracking on the same tag manager, do i need to copy tag manager tracking code on both the domains i.e. source and destination domain?
    Secondly, I need to track the ‘Pay now’ clicks on the destination domain from the analytics of the source domain.
    Here’s the scenario: On the source domain I have a product link which goes directly to another domain, on this domain we have a ‘pay now’ option. We need to track this ‘pay now’ clicks and record them in source domain analytics. I need to use GA and GTM to do this.

    Please advice on what changes should I do in analytics or tag manager.

    Thanks in advance.

    • Dan Wilkerson

      Hi Dave,

      That’s a really complicated question – unfortunately, it would take me a very long time (and lots of back and forth with you!) in order to figure out the absolute most appropriate steps. You’re heading in the right direction; a little trial and error and you should be able to get what you’re looking for.

      Dan

      • davepatrick

        Dan,

        I have been struggling with this for about a week now. I will be very thankful to you if we can solve the problem on a urgent basis. I am ready to go back and forth only if its not of any trouble to you.

        Thanks,
        Dave

  • JR Hopwood

    Dan,
    A bit stumped… I have a site where a visitor goes through several different domains until ultimately arriving at the conversion. So a typical visitor flow would look something like this: http://www.site.com >> myaccount.site.com >> http://www.site.com >> subdomain.site.com >> http://www.OTHERsite.com (Conversion).

    I have GTM firing GA on every page throughout the process (using Omnibug and GA reporting to double-confirm that this is indeed happening as expected). I do see the ?_ga= Linker at the beginning of this flow (from http://www.site.com TO myaccount.site.com), however the latter part I do not. Subsequently, my conversions are reporting as either direct or referrals (from site.com). I have verified the following: site.com, OTHERsite.com listed in the GTM Constant Variable that populates {{Auto Link Domains}} (see screenshot). site.com, OTHERsite.com are both listed in the Referral Exclusion list without the “www” and as two separate line items (as you show in your screenshot). Is there any reason that auto-linking would stop after doing it once? Or should it fire for any of the listed domains? Any thoughts would be “greatly” appreciated! Thanks Dan!
    -JR

    • JR Hopwood

      A redirect!! That was the problem. Even though the ?_ga= tag was on the initial link, that link redirected to OTHERsite.com. The redirect did not carry over the ?_ga= tag and that seems to be where I was losing tracking. So everyone reading this… be mindful of redirects!! 🙂

      • Dan Wilkerson

        Glad I could help 😉

        Dan

  • Vani

    Hi Dan,

    Your post is very useful.

    I have a clarification regarding cross domain tracking

    From a new microsite with a different domain name Visitors would land on my main domain.

    I have GTM on my main domain and i have updated the cross domain variable to include the new microsite domain name and all the allowlinker is set to true and it is firing on all pages.

    Now on my microsite i have added the below tags

    ga(‘create’, ‘UA-xxxxxxxx-x’, ‘auto’, {‘allowLinker’: true});

    ga(‘require’, ‘linker’);

    ga(‘linker:autoLink’, [‘main domain name alone] );

    I could see the _ga=1.98408732.2092043187.14556416 getting appended when visitors from microsite land on my main site. However in Goals i dont see the microsite data (which is step 1) and all i see is the main domain data (Which is step 2 & Step 3)

    Is there anything iam missing?

    Any help ?

    • Dan Wilkerson

      Hi Vani,

      I answered your question above!

      Dan

  • Vani Rajan

    Hi Dan,

    I have a clarification regarding cross domain tracking

    From a new microsite with a different domain name Visitors would land on my main domain.

    I have GTM on my main domain and i have updated the cross domain variable to include the new microsite domain name and all the allowlinker is set to true and it is firing on all pages.

    Now on my microsite i have added the below tags

    ga(‘create’, ‘UA-xxxxxxxx-x’, ‘auto’, {‘allowLinker’: true});

    ga(‘require’, ‘linker’);

    ga(‘linker:autoLink’, [‘main domain name alone] );

    I could see the _ga=1.98408732.2092043187.14556416 getting appended when visitors from microsite land on my main site. However in Goals i dont see the microsite data (which is step 1) and all i see is the main domain data (Which is step 2 & Step 3)

    Any help ?

    • Dan Wilkerson

      Hi Vani,

      Here are three diagnostics you can try:

      1. Check the Behavior -> Site Content -> Network report but change the Primary Dimension to hostname. Verify you do not see traffic from your microsite host.

      2. Verify that you’ve got the same UA number on the main domain and the microsite.

      3. Tag your self w/ custom parameter (utm_source=test&utm_medium=test), then find your session in the Real Time reports and travel through the site. Verify you don’t see pageviews from your microsite in the Realtime reports.

      If 1 is the culprit, you need to add the Hostname transposing filter. You do have pageviews from your microsite, they’re just being collated with pageviews from your main site with identical paths.

      If 2 is the problem, match up your UA numbers.

      If 3 is the issue, check your filters and ensure you’re not excluding the data w/ a filter. If not, there is an issue with the on-page code on the site, for some reason. Then you’ve got to do some code troubleshooting!

      Dan

      • Vani

        Hi Dan,

        Thanks for the quick response.

        1) When i look at Network report i am able to see the traffic from my microsite.
        2) I have used the same UA number on both main domain and the microsite

        Some more info i would like to add:

        The microsite has GA analytics.js tags and the microsite is built on angularjs.
        Under pages report of my main profile i am able to see microsite pages data and all the subpages under it (The URL’s are different to the main domain so definitely the traffic is not grouped under one page), but only when i create goals or in navigation report, i dont see them.

        Below are the tags i have added exactly to my microsite. The pageview is being sent manually and hence the last line ga(send, pageview) is not included

        (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);
        ga(‘create’, ‘UA-XXXXXXX-X’, ‘auto’, {‘allowLinker’: true});
        ga(‘require’, ‘linker’);
        ga(‘linker:autoLink’, [‘main domain name alone’] );

        Pls lee me know if there is anything wrong here.

        Thanks

        • Dan Wilkerson

          Hi Vani,

          Okay; are your URLs stored in the fragment? You’ll need to configure GA to send the fragment with the page view request, as it’s not included by default. You can do this by using Analytics debugger plugin:

          the https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

          Can you verify the destination URLs you are trying to use are appearing in the data? If no, then check that you don’t have a filter in place that is excluding those hits.

          Beyond those diagnostics, things venture into specificity-land; I won’t be able to help you if these don’t do the trick.

          Dan

          • Vani

            Hi Dan,

            Thanks again for your quick response.

            I will try enabling to track URL fragments as Pageviews and i will let you know how it goes tommorrow.

            My destination URL is a page within my main domain (with a unique URL created for microsite) and i can see those destination pages in the pages report and i can see them in my Goals which are step 2 and Step 3(Thanks You page). Step 1 is the challenge which is my microsite page

            Thanks for your help throughout.

  • ThomasA

    Hi there.

    I have this scenario:
    I have about 200 landingpages with different domains: landing1.com, landing 2.com….landing200.com
    Then I have a conversion.com domain, where the conversion happens.
    All the 201 domains are tracked in 1 Analytics profile with the same GTM container.
    We run facebook campaigns for all the 200 Landingpages but at the moment, the campaigns are not associated with the conversions.
    How do I need to set things up in order to make it work?

    Any help is really appreciated…

    • Dan Wilkerson

      Hi Thomas!

      If the landing domains share any kind of naming patterns, you can use regular expressions to match many domains. Failing that, you can try and provide all 200 domains to the Auto Link Domains parameter, although I am unsure of how that will behave.

      If they do not behave, or that isn’t possible, there is a somewhat hacky solution I’ve used in the past. You’ll need to write a little custom code; basically, you’ll want to extract the Client ID from your tracker using tracker.get(‘clientId’). Next, produce a hashed ID based on the UA of the browser and combine that with a timestamp. Then, append that parameter to ALL links on the page (I usually add it to the anchor and use my own key, e.g. _uga=1924125123.12395812931.12399581231.2328412. You’ll want to wrap all of this inside of a mousedown handler. Finally, add some custom code to detect your new parameter, extract it’s value, and check the following:
      – A new hashcode from the current UA matches the stored hashcode
      – The timestamp is less than two minutes old

      If those conditions are met, you can then set the stored client ID from your parameter to the clientId Field to Set. Just make sure you do this on the very first hit you send, and you’ll be all set!

      Hope this helps.

      Dan

      • ThomasA

        Hi Dan,

        thanks a lot for the info! Actually all domains share a pattern which sound good. But that leads me to these questions:

        – IN GTM, under “Auto Link Domain” can I use a combination of domains and regexp patterns?something like that: landing1.com, .*landing.*com
        – Under Referral Exclusion list in GA can I use Reg Exp as well? I didn’t find anything in the Google Analytics Help about this. i.e. : .*landing.*com

  • guest

    Hello,

    I am tracking multiple domains and subdomains with one google analytics account set up with GTM (as described in article):
    example.com
    app.example.com
    example.de
    example.es

    I know google analytics needs to add _ga parameter in url in order to send information from example.com to expample.de (different domains) but it also add those parameters when there is simple visit only across subdomains like this:
    example.com -> app.example.com

    Is it possible to avoid _ga parameters being added across subdomains?

    The visits across main domains are minority. Most visits are within the same domain and those _ga parameters are causing some troubles I did not have when I was tracking main domains separately.

    Thanks in advance!

    • Dan Wilkerson

      Hi there!

      So you want to treat users who visit those subdomains as different users? That’s a good one! You could try hard-specifying the domain using a regular expression, e.g. ^example.com$, and seeing if that works; a little trial and error should get you squared away.

      Dan

  • Mark Fissell

    Dan,
    Thanks a million for the post. And for following up to all the commenters.

    Have you, or anyone ever seen this error when testing an implementation: “Linker disabled. Ignoring linker parameter: 1.93452445.1899836353.1456948429”? (In my tests, I’m passing only required source, medium and campaign parameters) Here’s a screen shot attached

    My implementation is – Single Property ID, Two GTM containers, one on ‘siteA.digital’ and the other on ‘siteB.com’ (the siteB.com is a third party registration system, but GTM container is a non standard implementation.

    The containers are both setup identically according to the steps 1-4 listed above

    Any ideas on what I might be setting incorrectly?

    Appreciate any feedback!
    Mark

    • Dan Wilkerson

      Hi Mark,

      This typically means the tracker in question does not have allowLinker set to true (step 3 above). If you have other trackers firing on the page (it sounds like you might), they would be logging this message as that individual tracker detected the _ga parameter and ignored it. As long as you can verify the _ga cookie is being set and your tags have allowLinker, you should be set and can safely ignore that message – it wouldn’t hurt to verify that the hit that message is associated with is not being sent to your production UA, and that there IS a hit where the successful detection message is present.

      Dan

      • Mark Fissell

        Thanks, Dan! Still tweaking. In the meantime, does firing order have impact on tags? Or does duplication of a page view tag create a potential issue?

        I’ve verified that allowLinker is activated on the tags. The third-party site which is siteB.com (the destination site) in this example likely has a duplicate of the pageview tag. The first instance of that tag is added using a web console on their admin system…the third-party does not allow access to their source code and does not

        The second instance is the GTM container I placed on the pages of the third party site using their proprietary tag management system. My GA pageview tag in the GTM container is the one that I have verified has allowLinker set.

        I’m hopeful that despite a duplicate pageview tag, the firing order will not prevent the second tag’s allowLinker from working as I can see that my GTM cointainer tag is on line 100 of the source code and the third-party’s injected tag of the same pageview tag is a few hundred lines lower. What do you think?

        • Dan Wilkerson

          Hi Mark,

          It sounds like what will happen is this:

          1) Their pageview tag will fire, generating a new Client ID
          2) Your pageview tag will fire and replace the newly generated Client ID with the Client ID from the _ga parameter.

          Obviously this is not idea, as you’ll be (inadvertently) inflating their users/sessions/pageviews. You should reach out and see if they could add ‘allowLinker’ to their snippet – that would solve for all problems.

          Dan

  • http://maebellyneventura.com Maebellyne Ventura

    Dan,
    Great post, managed to set up tracking across subdomains which is working like a beaut! However, is there a way to hide the linker parameter _ga=1.22828347.1670321291.1456828593 from the URL that users see?

    • Dan Wilkerson

      Hi Maebellyne,

      You can by using the History API, but it’s not a simple fix.

      Dan

  • TaniaSteenkamp

    Hey Dan!

    Just want to check…If I want to cross track domains b.com and c.com inside domain a.com, do I place both pageview tags inside container for b.com and inside container for c.com?

    Or just follow the steps above with on UA tag on each site?

    • Dan Wilkerson

      Hi Tania,

      Just follow the above steps!

  • marzio

    Hi Dan, great tutorial!

    I’m trying to implement cross domain tracking and i have a question. I’m tracking mysite.com and actually i’m using mysite.externalshoppingcart.com that goes to paypal to collect sales and then back to mysite.com to deliver the product.

    I implemented what you wrote but i see all sales being attributed to PayPal, what does this means? Do i need to add paypal to the exclusion list?

    thanks

    • Dan Wilkerson

      Yes, add paypal.com to your referral exclusion list.

  • ThomasT

    Hi Dan

    Will the cross domain setup work for source/medium referral sites like Eloqua?

    For example we have a site where the form is on the site, submits to Eloqua, then redirects to a thank you page on the site again.

    example.com/form.html >> submits to Eloqua >> Redirects back to example.com/thanks.html

    • Dan Wilkerson

      Hi Thomas,

      If Eloqua supports cross domain tracking, then you’d set up your domain list with both your own site and your Eloqua domain. If not, you don’t need to set up cross domain tracking; you just need to add eloqua.com to your Referral Exclusion list.

      Dan

  • cesaringo

    Hi. What about include the ID client in the forms?

    • Dan Wilkerson

      Hi Cesar,

      You’ll want to set Decorate Forms to True; screenshot attached!

      Dan

  • LordEVon

    Hi.
    I need some help.
    We have some page. There is a main main domain (hotel-residence.hu), there is a subdomain (balaton.hotel-residence.hu) and an external booking address.
    I’d like to see the whole traffic in the subdomain. So, I want to know where they come to main domain and to subdomain. The main domain has to give over the tracking data to subdomain, and the subdomain has to give over the tracking data to shopping address.
    How should I do it?

    Thanks

    • Dan Wilkerson

      Hi LordEVon,

      You’ll want to configure cookieDomain to auto and add the external booking address as a cross domain site, if you can add code there. If you can’t add code on your external site, you’ll want to add it to your referral exclusion list.

      Dan

  • Will Bebee

    Hey Dan,

    Great article, I’ve read and re-read several times but still unsure if I need to implement Cross Domain Tracking. We have several (14 domains) that customers can jump between, the problem is that if they’re coming from AdWords/Bing/acquisition channel, and then jump to another domain, the parameters and the conversion is counted as referral. In this scenario, if I implement cross domain tracking, will it instead be attributed to the appropriate acquisition channel?

    • Dan Wilkerson

      Hi Will,

      Yup, if you follow all of the above steps, you’ll get exactly what you’re looking for!

      Dan

  • Ben

    Hello

    do all domains and subdomains need to be under the same GTM container tag?

    thanks
    ben

    • Dan Wilkerson

      Hi Ben,

      Not necessarily! You can use multiple containers (and it often makes sense to do so). Just make sure that they all have the same Cross Domain configurations.

      Dan

      • Ben

        Hi Dan

        once done how can i see is GA how much traffic has come from a certain subdomain

  • Mateus Araújo Lopes

    Hello Dan, great article!

    In my case, a specific step redirect the http://mysite.com/payment/new to http://subdom.mysite.com/sat. I don’t have buttons or links, works too?

    • Dan Wilkerson

      Hi Mateus,

      You’re interested in subdomain tracking – set the cookieDomain field to ‘auto’ on all of your Google Analytics tags and you’ll be all set!

      Dan

      • Mateus Araújo Lopes

        The url is a subdomain of reverse proxy, I don’t have control about the page that is in other server.

        • Dan Wilkerson

          Hm, I’m not following your question. Can you be more specific?

  • Eric Barnes

    Would this work for timed redirects?
    After 5 seconds the page redirects to the next domain.

    • Dan Wilkerson

      Hi Eric,

      Not without additional code; you’ll need to teach your redirect to retrieve the clientId and then append it to the redirection URL.

      Dan

      • Eric Barnes

        Thank you!

  • Sam Johnson

    Hey Dan,

    Great article thanks for writing. I’m trying to track the number of sessions that go from one domain to another so Example1.com to example2.com. Any advice on this?

    Thanks,
    Sam

    • Dan Wilkerson

      Hi Sam,

      Sure! Create a session-level Segment with the conditions hostname contains example1.com and hostname contains example2.com, and that will show you only sessions with hits from both domains.

      Dan

  • Bromdog Brom

    Thanks for the article.

    After almost a year I noticed I forgot to set the allowLinker en cookieDomain parameters in GTM version 2. What are the consequences?

    • Dan Wilkerson

      Hi Bromdog,

      Well, your cross domain tracking probably isn’t working. Without that parameter, Google Analytics ignores the _ga parameter on a cross domain click, and if you’re tracking users across subdomains, it will generate a new client ID for each subdomain they visit, too.

      Dan

      • Bromdog Brom

        Hi Dan,

        Thanks for your answer.

        I fixed the configuration.

        I am using cross-domain tracking for several domains. I included all domains in the referral exclusion list, because a visitor should not trigger multiple sessions when there should only be one.

        Unfortunately source traffic from the excluded domains is categorized as “direct/none”. This makes it impossible to find out which domains refer to one another.

        How can I configure GTM and/or GA so that the domains show up as source without adding extra sessions?

  • Patryk Kalinowski

    Thanks for the article.

  • Astrid

    Hello Dan

    This appears to be a post that just keeps on giving 🙂 Thank you for your perseverance, if it does not extend to me, I promise I won’t blame you.

    My issue:

    —-Roll up tracking coupled with cross domain tracking? On top of individual tracking? Through GTM?—-

    I currently have six domains, six GTM containers and four GA properties. Domain 1 has cross domain tracking set up with domain 5 and 6 and reports to the same GA property 1.

    The desired setup preserves this cross domain tracking to roperty 1 alongside, tracking to property 2 from domain 2, 3 to 3 and 4 to 4.

    Further a new property X which receives for a start just basic hit data from each of the six domains but with cookie preservation i.e. cross domain tracking.

    I could of course create that new property, add UA pageview tags to each of the six containers specifying the new UA-id, add allowlinker true to them and create and add variables to each container detailing auto linked domains…

    But I read so much about the trackers needing to be named when more than one tracking object is used on the same domain? And then when you name trackers, it seems everything becomes very risky business?

    And will I have to duplicate all tags on each containers that I wish to track in property X?

    Again – thank you regardless.

    Astrid

    • Dan Wilkerson

      Hi Astrid,

      If you’re using GTM, you don’t have to worry about naming trackers; GTM does that for you. You can disregard advice to that effect (and should, as named trackers via GTM are pretty problematic).

      In terms of your cross domain tracking setup, I’m having a little trouble understanding your setup; this insight might help, though:

      A user in Google Analytics is a unique User ID coupled with a unique Property ID. If you have Property X and Property Z on domain A, and Property X and Property Y on domain B, and you configure cross domain tracking between the two domains, you’ll have:

      1 User for Property X
      1 User for Property Y
      1 User for Property Z

      They’ll treat each user in exclusion from one another. In terms of tracking the same things to multiple properties, you’re pretty much stuck with duplicating your tags and changing your UA number, although Simo Ahava has a technical workaround you could try here:

      http://www.simoahava.com/analytics/firing-a-single-tag-multiple-times-in-gtm/#gref

      Dan

  • Stephen

    Many thanks for this – Glad that it is very easy to do. Guidelines for how to do it would be really great!

    tagflair.com

  • Olgierd Nowakowski

    Hi Dan,

    Great and very consise article. Just one question – do I have to deploy the same GTM container on domains/subdomains that I want to track? I have a situation in which I collect data on one subdomain with our own GTM container but need to include traffic from other subdomain that has its own container. What would you advise?

    • Dan Wilkerson

      Hi Olgierd,

      This may or may not be a good idea; it depends on how much duplication of tags you’ll have between domains. You can also just create a new container or add a tag to the existing second container that pushes data to the same property as your first!

      Hope this helps.

      Dan

      • Olgierd Nowakowski

        Hi Dan,

        Thanks your your quick reply – it helps a lot. Probably will go with adding tag to the second container – seems more reliable and secure to me. But here is quick follow-up question: will the subdomain tracking work in this case and do I need set cookieDomain to ‘auto’ in this tag added to second container? Sorry if it seems trivial but it still puzzles me.

        • Dan Wilkerson

          Hi Olgierd,

          It kind of depends – you’ll probably want to match the cookieDomain setting of the pageview tag currently in the container. If these are both two different subdomains, you actually don’t need to do cross domain tracking at all.

          Dan

          • Olgierd Nowakowski

            Hi Dan,

            After giving it a second thought I think that creating new container would the least problematic – especially when it comes to data integrity.
            Word of clarification: data flow looks like this: campaign->second subdomain->my subdomain

            My ultimate goal is to see original source/medium campaign data in my subdomain but without excluding information about intermediate step (second subdomain).
            Therefore I’ll try to add pageview tag to this new container on second subdomain with cookieDomain set to auto.
            Do you think this is the way to do it or simply deploying the same GATC on both subdomains would suffice even without cookieDomain set to auto?

  • Laura

    I followed all of the steps above and while the cross domain tracking is working correctly, I’m having an issue with the parameter (?_ga=1.210371479.3429707736.1432831029) still appearing on URLs of the autolinked domains even after I finished the testing step and changed “Use Debug Version” back to false. Is that supposed to be happening?

    • Dan Wilkerson

      Hi Laura,

      Yes, the tracking depends on that parameter. It’s how Google Analytics circumvents the same-origin policy of browser cookies.

      Dan

      • Laura

        Thanks for your response, that makes sense. However, I am concerned about this parameter breaking links though. I had a somewhat complex link that broke when the parameter was added. I was only able to fix it by not autolinking that domain for now. Is there any way around this?

        • Dan Wilkerson

          Hi Laura,

          Reconfigure your tag to use the hash as the delimiter by changing the associated field to True – see attached screenshot. That should solve your problem.

          Dan

          • Dan Wilkerson

            Better screenshot:

  • powers17

    Hi Dan, I was looking for the best way to do a roll up GA profile and found your post. Would this accomplish my goal? Basically I have 3 subdomains with 3 separate UA IDs in 3 separate GTM containers. Assuming I want to see all the inter-activity within 1 Google Analytics roll-up profile, what would be the best way to accomplish this? It was suggested to me to either add a new second GTM container to all 3 sites with the same (new) ID, or, add a second GA Tag (with the same UA-ID) to each existing container. Thoughts?

    • Dan Wilkerson

      Although it’s supported to add two containers, it’s not advised – you’re better off adding a rollup tag to each container.

      Dan

  • Sergey

    Hi, I have a question. Our set-up across three different domain seems to work right only in Chrome. How our check out works: User start at a domain A – then go to domain B – and the final “check out” and conversion is at domain C. I tested it with “utm_source/medium/campaign=test” and the conversion on the 3rd domain in Chrome was attributed to “test” – which is right. But, on Firefox and Explorer it keeps getting attributed to “direct” traffic, no matter what UTMs I am testing with.
    Any ideas where to look at for the problem’s source?

    • Dan Wilkerson

      Hi Sergey,

      Are you using the native cross domain tracking in GTM? Do you have any other potential considerations that might bork things? (redirections, etc)

      Dan

      • Sergey

        Thank you for the fast reply, Dan.

        Actually I tested more in Chrome and even in Chrome now it shows all the bookings as direct traffic. To answer your questions and elaborate more:

        1. Yes, we use native cross domain tracking in GTM

        2. There is a redirect from domain A to domain B, and domain B is where it looks like the problem is, because I don’t see any cross-domain “tagging” at the end of URLs at the domain B (ex: &_ga=x.xxxxxxxx), I only see those tags in the URL of the last domain C.

        3. A little more how it works:

        – Main website – A – is where users enter a range of dates to book a room
        – After they press “book now” it redirects them to domain B and passes some information (such is time and date and more) in the URL.
        – After they select a room, they go to the secure domain C, the only place where I see that &_ga=x.xxxx link extension
        – If I press on a logo and go back to the domain A – main site – I see that “&_ga=x.xxx” in the URL as well (I don’t see it in the beginning, only when go from C to A, and I never see it at all on the domain B no matter what I do).

        Any thoughts?

  • Marcos Nobre

    Hi Dan,

    Thanks a lot for your article, really helpful indeed. I think I’m almost there but I need to decorate an iframe source URL with a different parameter name for the client id. Do know how to do that?
    I’m trying to set up cross-domain conversion tracking on Eventbrite and they require the parameter to be called _eboga:
    https://www.eventbrite.com/support/articles/en_US/Troubleshooting/how-to-enable-cross-domain-and-ecommerce-tracking-with-google-universal-analytics?lg=en_US

    Any help would be much appreciated.
    Many thanks,
    Marcos

    • Dan Wilkerson

      Hi Marcos,

      Unfortunately, you’re going to need to write everything from scratch – you’ll want to use the tracker.get(‘clientId’); method I mention elsewhere in the comments here, plus you’ll need to write a mousedown listener for all relevant links that decorates the link with the aforementioned parameter.

      Dan

      • Marcos Nobre

        Hi Dan,

        Thanks for the quick reply. I was hoping to avoid writing any code. I will try the solution below from
        https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#iframes

        Do you know whether there is a way to append that to the UA tag to re-use its configuration?
        Thanks a lot!

        ga(function(tracker) {
        // Gets the client ID of the default tracker.
        var clientId = tracker.get(‘clientId’);

        // Gets a reference to the window object of the destionation iframe.
        var frameWindow = document.getElementById(‘registration-frame’).contentWindow;

        // Sends the client ID to the window inside the destination frame.
        frameWindow.postMessage(clientId, ‘https://eventbrite.co.uk/tickets-external?eid=20575544006&ref=etckt&_eboga=’+clientId);
        });

  • Jim

    Dan,
    This article is very helpful but raised a few more questions for me. Is all subdomain and cross-domain tracking usually set up in one property? Can any of it be done across different properties? Would that require double (or triple) tagging your sites? Or could we use different properties and just be tracking the user sessions between sites and not the actual pages? If we were subdomain tracking 5 sites in one property would we then set up new views and filters to show different combinations of those sites? Do subdomain and cross-domain tracked sites show up the same in GA reports (you see pages from both sites in the reports, if appropriate filters are applied)?
    Thanks!

  • Jamse

    Hi Dan,

    Great article!

    I am currently using cross-domain tracking AND using the cookieDomain value auto for subdomains (www.mysite.com, thehub.mysite.com and support.mysite.com). Now for some reason the _ga parameter is being appended when you click from the the homepage (www) to the support site (support) but not when you go from the homepage to the blog (thehub). The parameter you get when going to support.mysite.com persists when I link back to either the homepage or the blog subdomain.

    My understanding is that, as these are subdomains, neither should have the _ga parameter.

    Is this a correct way of thinking?
    And also, what can I troubleshoot to find out why one subdomain is tracking as if its a cross-domain site?

    Many thanks in advance if you can help!
    James

  • Mike

    Hi Dan,

    We have two websites and would like to implement cross domain tracking, do we need to tag both websites with a google tag manager with the same GA code before doing the steps above?

  • cenxanane

    Hi Dan, first of thank you for this valuable post.

    For now, each websites on our network which run on different subdomains tracked by separated GA accounts! We plan to track and see whole our network’s traffic by single property, and differentiated the websites by their Views by using Filters.

    I just followed all steps you mentioned above on your post, and created a new GA Account, a new GTM and implemented them. In order to make sure that results are correct, I kept existing GA tracking code. Once I looked at the numbers, Users, and Sessions are the same but GTM’s pageviews got doubled.

    Can you please tell me how to fixed this problem? I need a proof that new system works fine so that I must compare the numbers too.

    Thanks in advance

  • Sam Han

    Hi, Dan. I have confronted with a similar problem as davepatrick. I hope you have solved this. I want to track a form with GTB, but I find the form is written in an iframe with another domain. I set form submission as a conversion but GTB doesn’t work. Could you please do me a favor?

  • Andrea Lyn Van

    When setting up an event tag the Cross-Domain tracking does not seem to be available in the new UI and I can’t find it anywhere. Any suggestions?

Contact Us.

LunaMetrics

24 S. 18th Street, Suite 100,
Pittsburgh, PA 15203

Follow Us

1.877.220.LUNA

1.412.381.5500

getinfo@lunametrics.com

Questions?
We'll get back to you
in ONE business day.