Cross Domain and Subdomain Tracking using Google Tag Manager

Cross Domain and Subdomain Tracking using Google Tag Manager

Many websites today are made up of several smaller sites, often with different domains and subdomains. Your organization may have a main, along with,, or You may also have distinct domains for different brands or campaign microsites, like or

When it comes to configuring analytics tracking for your family of websites, proper handling of different domains and subdomains is critical to ensuring the quality of your data. Otherwise, you will have fragmented sessions, inflated metrics, and unattributable conversions.

If you are tracking multiple domains or subdomains in the same Google Analytics property, you must properly configure cookie settings, referral exclusions, and cross-domain tracking in order to connect a visitor’s session across domains. Luckily, Google Tag Manager makes subdomains and cross-domain tracking easy to implement.

Subdomain Tracking

Tracking across subdomains requires only a simple configuration, which you may already have enabled by default:

  1. In GTM, set the Cookie Domain field to auto.
    • This tells Google Analytics to set its cookie on the primary portion of your domain. Why is this important? Well, if you have,, and, a cookie set on will apply to all of them. This means that Google Analytics will be able to continue tracking a visitor no matter which subdomains they visit within their session.
    • The cookie domain is set to auto by default if you are using a Google Analytics Settings variable:
    • If you are not using a Google Analytics Settings variable, you should be! If however you need to quickly update an existing implementation, you can set cookieDomain to auto by adding a field under Fields to Set in your base Google Analytics page view tag:
  2. In Google Analytics, update the Referral Exclusion List.
    • Ensure that your primary domain is on the Referral Exclusion List (Admin > Select a Property > Tracking Info > Referral Exclusion List).
    • Adding the primary domain to the list (e.g. will also cover all subdomains. Alternatively, you can add each subdomain individually (e.g.,,

Cross Domain Tracking

Tracking across distinct domains with Google Analytics requires a few more steps, but can still be implemented through Google Tag Manager. The following should be done in your Google Analytics Settings variable (or within your base Google Analytics page view tag, if you are not using a GA Settings variable):

  1. Set the Cookie Domain to auto.
    • This ensures that GA will select the best domain for the cookie.
    • If you are using a GA Settings variable, the cookie domain is set to auto by default:
    • If you are not yet using a Google Analytics Settings variable, you can add a Field to Set which sets cookieDomain to auto on your base GA page view tag:
  2. Enable Cross-Domain auto-linking by entering a list of domains.
    • Enter a comma-separated list of domains into the Auto Link Domains field under the Cross-Domain Tracking section (e.g.,,
    • This tells GTM to transfer the GA cookie information between domains when the user clicks from one domain to another. This is what adds the _ga= parameter to the URL.
  3. Set the Allow Linker field to true
    • Add a field for allowLinker and set to true:
    • This enables GA to retrieve cookie information from the _ga parameter in the URL.
  4. Update the Referral Exclusion List in Google Analytics
    • In GA, you should ensure that all domains added to the cross-domain list in Step 2 above are also on the Referral Exclusion List (Admin > Select a Property > Tracking Info > Referral Exclusion List):
      Referral Exclusion List

Have you experienced issues with cross-domain tracking? Are your own domains showing up as referral traffic? Let us know in the comments below. We’re happy to help!


Photo credit: Matt Wiebe, CC BY 2.0

By |2019-05-17T11:57:13-04:00November 22, 2017|33 Comments


  1. Elod 2018-01-22 at 04:10 - Reply

    Hi, I have a blog on a different domain. Is it possible to measur it together? My website is “”, and my blog is Is it possible to use the above mentiones method to ttack these?

    • Marc Soares 2018-01-23 at 09:35 - Reply

      Yes, you would need to implement the cross-domain tracking method described above.

  2. Adam 2018-01-28 at 20:59 - Reply

    We are definitely seeing self referrals. Our site is
    We recently upgraded from the old legacy analytics (before universal) to the new
    We installed the code manually into the head include file for our site and then on the various sub domains . When I look at our report – I see the referral is and when I click on that referral , I see / as the top referring page. We have in exclusion list.
    Would love any input you can provide.

    • Heather Murphy 2018-01-29 at 13:29 - Reply

      Hi Adam,

      If you have recently upgraded from Classic GA to gtag.js, it is likely that you will still see self referrals in your reports. The Referral Exclusion List is a feature of Universal Analytics, and as such, the referral campaign may be persisting from before the upgrade. Campaigns have a time out period of six months, therefore we would expect the volume of self referrals to decline over time.

      A simple way to ensure self referrals are no longer an issue is to look at the number of new users – we would expect to see no new users with a self referral after the upgrade happened.


  3. Adam 2018-01-29 at 14:48 - Reply

    Thank you Heather. One last question – do you advise we just deploy the universal snippet code from gtm if we plan on using that – instead of using the gtag.js snippet? or should we use the new gtag.js and then also use GTM to deploy our tags? I know there are benefits to deploying analytics tracking code using GTM – but not sure if it matters with the new gtag.js.

    • Heather Murphy 2018-01-30 at 10:04 - Reply

      Hi Adam,

      If you are planning on using GTM, we would recommend deploying your GA code through here as well. A tag management system will allow changes to easily be made to your analytics configuration without needing to regularly modify code directly on your site.



  4. Anna 2018-02-21 at 03:15 - Reply

    Hi! Thank you for addressing the topic of cross-domain and subdomain tracking.

    I have the following case: my main domain and the subdomain are set up as different properties in GA. I am using Global Site Tag (gtag.js) tracking code for each property, and I have added the main domain to the Referral Exclusion List for the main domain property. I would like to track conversions (e.g. sign-ups) from traffic originated at the subdomain. So, my questions are:
    1. Will I be able to track conversions (e.g. sign up) from subdomains on my main domain property, if, in GTM, I set the Cookie Domain field to auto?
    2. Should I use UTM tracking code on my subdomain links, if subdomain tracking is set to “auto”?

    • Heather Murphy 2018-02-23 at 09:50 - Reply

      Hi Anna,

      Thanks for your comment.

      Given your current set up, we would recommend modifying the Referral Exclusion List on the main domain property to include the prefix of www (i.e. www(dot)example(dot)com). With this specification, will be considered a referral to the main property. You will then be able to see blog referrals without needing to modify any settings in GTM, or using UTM tags.

      You may also wish to consider having an additional “roll-up” property, populated with data from both the main and sub domain. With proper subdomain tracking, having the two domains in the same property would allow you to more precisely track a user journey.


  5. Anna 2018-02-27 at 01:58 - Reply

    Thank you for your comment, Heather!

    so, if I add www(dot)example(dot)com) to the Referral Exclusion List in my main property, the other Subdomains (e.g. will be considered as Referrals, and I will be able to track the visits and conversions from that subdomain, right?

    • Heather Murphy 2018-02-27 at 09:10 - Reply

      Hi Anna,

      Yes – by specifying the www. in front of your primary domain on the Referral Exclusion list, you will be identifying that specific URL. Therefore, the blog. subdomain will be considered a referral.


  6. Anna 2018-02-28 at 05:52 - Reply

    Thank you Heather! You helped me a lot!

  7. liad 2018-06-07 at 03:52 - Reply

    I’m using Gtag.js and currently my site vistors on first visit my site, then move to and complete my form and then return to This is tracked in google analtics on both domains but referral exlclusion list isn’t working and is being treated as the source of my traffic. how do i tell ga that is my site too. i want GA to show me the true source of traffic.

    • Heather Murphy 2018-06-08 at 10:47 - Reply

      Hi Liad,

      Thanks for your comment!

      If you recently added to the Referral Exclusion List, it is possible that individuals are returning directly, and the campaign is persisting – GA campaigns have a 6 month timeout by default. You can look at “New Users” with this campaign to confirm.

      Alternatively, have you confirmed that the Cookie Parameters are being appended as expected between domains? You may need to turn on “Decorate Forms” in the Cross Domain Tracking settings, assuming it is a standard form submission.


  8. Ronald 2018-06-07 at 22:47 - Reply

    Hi Heather,

    Would really appreciate some help as I am needing to cross-domain across various properties with a mixed GTM and GA snippet implementation and have never had to do do it on messy implementation across a silo’d organisation. Some properties are a different domain, others are subdomains managed by other business units with separate direct GA implementations. So here are my questions:

    1) Even though some sites are subdomains, they are separately hosted from the main domain and have their own GTM or GA implementation. Do I then just follow the cross-domain instructions in addition to the subdomain instructions?
    2) OR, subdomain instructions are sufficient?
    3) as we have a multitude of subdomains that do not have tracking implemented (not required), but still has users traverse through them, should I be explicitly declaring each subdomain in each properties referral exclusion list instead of just the main domain?

    Thanks in advance.

    • Heather Murphy 2018-06-08 at 17:31 - Reply

      Hi Ronald,

      Cross-domain tracking is only effective if all domains are tracked in the same GA property. Assuming this, you will need to set up the cross domain tracking in each GTM containers.

      When following the cross-domain instructions, you can declare the primary domain (ex. in the list of domains, which will cover all subdomains. It is not an issue that they are separately hosted. If you wish to link only some of the subdomains, however, you will need to declare each subdomain in your list of domains to auto-link (ex.,, …).

      Similarly, you will want to put the primary domain, or each individual subdomain in your Referral Exclusion List depending on how you want to treat the non-tracked sites.

      Cross-domain tracking set up in GTM will not apply to the sites that have a hard-coded GA implementation. Both the cookie domain and autolink settings will have to be hard-coded in the GA snippets.


  9. Ronald 2018-06-10 at 21:10 - Reply

    Thanks for clarifying Heather. Unfortunately, the way the organization is structured (University/College), different teams have complete ownership of different domains and each one is structured completely differently to the main site as they are purpose specific, ie. some are student/study portals, some are course registration pages. This is also the reason why some are in GTM, and others in GA.

    But just to be 100% on your advice above, this is a representative scenario of what we have going on.. it is not best practice and it won’t be fixable/consolidatable anytime soon… (Account 1, GA Property 1 via GTM) (Account 2, GA Property 2 via GTM) (Account 1, GA Property 3 via GTM) (Account 1, GA Property 4 via GTM) (Account 3, GA Property 5 via GTM) (Account 4, GA Property 6 via direct GA Snippet) (Account 4, GA Property 7 via direct GA Snippet)

    As for the gtm / ga implementations not cross-domaining… I was under the impression this would all work if the additional config settings in GA snippet (linker,domains,accept_incoming, decorate_forms, etc) were identical to the GTM equivalent of GA Settings variable (cookie domain, allowLinker field, autolink domains, decorate forms, etc)?

    • Heather Murphy 2018-06-11 at 15:59 - Reply

      Hi Ronald,

      Cross-domain tracking unifies a users journey across different sites, allowing you to see how they navigate between these sites within the same session. That being said, if the sites are in different GA properties, GA does not allow you to view these as the same session.

      The paid version of GA, Google Analytics 360, would allow you to create a roll-up property between these different properties. Without 360, we would recommend creating another GA property, and deploying this across all assets, effectively creating your own ‘roll-up property’. With the proper settings, you would then be able to see the full user journey across sites.

    • Ronald 2018-06-12 at 20:46 - Reply

      Thanks for all the clarification Heather. This public conversation trail may be what I need to get things fixed properly.

  10. abdul 2018-07-31 at 07:47 - Reply

    does this work with the following example:

    subdomain1. example . com > subdomain2. example . com > then go back to subdomain1.example . com/welcomepage

    is this trackable? to track conversions (Sign ups). is your method mentioned above applicable for this example. please help

    • Heather Murphy 2018-07-31 at 10:13 - Reply

      Hi Abdul,

      Yes, the subdomain tracking would be applicable in this particular scenario!


  11. Kamil 2018-09-05 at 01:05 - Reply

    Hej. Can you show more detail where is it in google analytics? I don’t seethe option to set up cookiedomain.

    • Heather Murphy 2018-09-05 at 09:59 - Reply

      Hi Kamil,

      If you are using GTM, the setting for cookieDomain will be set on the pageview tag, or set by default if you are using a GA Settings Variable.

      The only configuration required in Google Analytics is updating the Referral Exclusion List.


  12. Peter Graber 2018-10-24 at 15:40 - Reply

    Here’s my simple scenario: => via a directive in a vhost.conf file. I have many many many sub-domains.

    Using Universal GA.

    How can all redirects from various sub-domains be counted individually?

    • Heather Murphy 2018-10-25 at 11:00 - Reply

      Hi Peter,

      In your scenario, adding subdomain tracking to your analytics implementation will not be beneficial.

      You may consider adding an additional query parameter to your redirected URL to be able to differentiate the redirect in Google Analytics.


  13. Peter Graber 2018-10-25 at 14:12 - Reply

    Heather — Thank you so much for quick response!!! All examples I’ve seen hadn’t covered by scenario. Really appreciate your insight.

    For parameters, I assume you mean GA Custom Campaign parameters. Do you mean something like this in term of redirect URL (:

    • Heather Murphy 2018-10-26 at 11:15 - Reply

      Hi Peter,

      GA Custom Campaign parameters would work, yes. Do consider how you would like to classify this campaign, and any other impacts this may have on your implementation.

      Alternatively, you could also test adding a non-UTM parameter (eg. depending on your needs.


  14. Mrinal Mondal 2019-01-10 at 19:39 - Reply

    This article was amazing and informative! Thank you so much

  15. Charles 2020-06-03 at 16:14 - Reply

    What about domain and subdomain? How can I track conversions if I have a landing page on domain, and form for subscription on the subdomain? This refers to Google Ads, not Analytics.

    • Marc Soares 2020-06-03 at 16:43 - Reply

      Hi Charles,

      If you have Google Ads linked to Google Analytics, then it will be sufficient to follow the steps above to ensure you have proper cross-domain tracking in GA. If you are not using GA and only tracking conversions in Google Ads, then you should deploy a Conversion Linker tag through GTM (See here:


      • Charles 2020-06-04 at 15:54 - Reply

        Thank you very much 🙂

  16. Travis Rotenburger 2021-07-05 at 18:00 - Reply

    I have implemented referral exclusions in analytics, but I’m still receiving referrals from my subdomains. The referral exclusions were implemented quite some time ago, so I don’t believe it’s lag.

    We have our GTM container deployed across the entire web property. The container includes our UA variable, as well as a local UA variable that searches for other local analytics code. Is having two instances of UA running what is causing us to receive referral traffic? The referral exclusions are not setup on all of the local UA properties.

    • Nicole Harris 2021-07-08 at 11:41 - Reply

      Hi Travis, thank you for your question! When you say local UA variable we are assuming that you are referring to a custom JS variable, but please let us know if we are mistaken. It sounds like you are having an issue with receiving referrals from you subdomains and have multiple UA properties that do not have referral exclusions set up. In this case, we would advise you to set up referral exclusions across all of your properties. Please let us know if this solves the issue and if you have anymore questions!

Leave A Comment