Search
Clear search
Close search
Google apps
Main menu
true

Cross Domain Tracking

Google Tag Manager simplifies cross domain tracking in Google Analytics. With cross domain tracking, you track separate, top-level domains as a single entity, thereby combining data for multiple top-level domains together in the same Google Analytics reports. Two example domains, A.com and B.com, are used to illustrate.

Overview

Ordinarily, a new session is established and first party cookies are set once a user clicks over to a new domain. In order to maintain the session information from the first domain, you need to pass the cookies from the first domain to the second domain, and the second domain needs to give permission to do this. Without Google Tag Manager, you'd use the _link or _linkByPost APIs on all the links to B.com in order to pass the cookie values. You'd also need to use setAllowLinker on B.com to allow the cookies to be passed.

Google Tag Manager provides two ways of implementing cross domain tracking: via link and form decorator tags or through Universal Analytics' Auto Link Domains feature. Both simplify the process of cross domain tracking in Google Analytics.

  Link / Form decorator tags Auto Link Domains
Use with Google Analytics and Universal Analytics Universal Analytics only
Required Setup Create link or form based triggers that fire link or form decorator tags, passing Google Analytics cookie data across domain. Select the Auto Link Domains option on Universal Analytics tag.
Flexibility vs. Simplicity Most flexible, but requires setting up additional tags. Simple to enable, but less flexible.

Link / Form Decorator Tags

Google Tag Manager provides Link Click triggers and Form Submit triggers) that allow Google Tag Manager to know when a link is clicked or a form is submitted and fire tags accordingly. You set up a Google Analytics Decorate Link tag with a trigger that listens for clicks on links to B.com. Before sending the user over to the new site, the Google Analytics Decorate Link tag appends the cookie values from the A.com session to the B.com URL. Your Google Analytics Page View tag on B.com should have the Allow Linker option set, allowing the cookie values to be passed to B.com.
Similarly, you can use a form based trigger associated with a form decorator Google Analytics tag to pass cookie information from domain A to domain B when a form submission is the mechanism transferring the user across domain.

Auto Link Domains

The Universal Analytics Page View tag's Auto Link Domains option allows for automatic sending of the cookie values, while the allowLinker field setting grants the necessary permission from B.com. The Auto Link Domains option is the simpler option for cross domain tracking. However, it may be less flexible than the Auto Event Tracking approach in certain cases. Auto Link Domains may only be used with Universal Analytics.

Step by Step

Step by step instructions, for both link / form decorator tags and Auto Link Domains, are provided for the following:

  • How to track across the domains when the user clicks a link to B.com: link decorator tag and Auto Link Domains.
  • How to track across the domains when a user submits a form (for example, when the user completes a shopping form on A.com and moves to the checkout system on B.com): form decorator tag and Auto Link Domains.

Clicks from A.com to B.com (Link Decorator Tag)

In the container for A.com:

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. If you are using the same container for A.com and B.com, or if you want to allow bi-directional cross domain tracking (i.e. linking from B.com to A.com), under More Settings → Fields to Set, enter a new field with these values:
    1. Field Name: allowLinker
    2. Value: true
  3. Create a trigger based on the click event.
    1. Select Just Links as the trigger type.
    2. Name the trigger "outgoing link click to B.com". Enable this tag for when the url contains A.com.
    3. Add a second filter "element target contains B.com". Have the trigger fire when the click url contains B.com.
  4. Add a Google Analytics tag (Classic or Universal).
    1. Select "outgoing click from A.com to B.com" as the trigger.
    2. Select the Track Type to Decorate Link).
    3. Give the tag a name. (For example, "GA Link Decorator from A.com to B.com").
  5. Save a version of the container and publish it.

If you are using a separate container for B.com, in the container for B.com:

  1. Add a basic Google Analytics page tracking tag (Classic or Universal; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Under More Settings → Fields to Set, enter:
    1. Field Name: allowLinker
    2. Value: true
  3. Save a version of the container and publish it.

Clicks from A.com to B.com (Auto Link Domains)

In the container for A.com:

  1. Add a (or edit your existing) basic page tracking tag (i.e. Tag Type of Universal Analytics; Track Type of Page View).
  2. If you are using the same container for A.com and B.com, under More Settings → Fields to Set, enter the following:
    1. Field Name: allowLinker
    2. Value: true
    3. Cookie Domain: auto
  3. Find the field More settings → Cross Domain Tracking → Auto Link Domains and enter "B.com" (no quotes).
    If you have multiple domains, separate them by commas: A.com, B.com, C.com
  4. Set the trigger to "All Pages".
  5. Save a version of the container and publish it.

If you are using a separate container for B.com, in the container for B.com

  1. Add a (or edit your existing) basic page tracking tag (i.e. Tag Type of Universal Analytics; Track Type of Page View).
  2. Under More Settings → Fields to Set:
    1. Field Name: allowLinker
    2. ​​Value: true
  3. Save a version of the container and publish it.

Form Submits from A.com to B.com (Form Decorator Tag)

In the container for A.com

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. If you are using the same container for A.com and B.com, or if you want to allow bi-directional cross domain tracking (i.e. linking from B.com to A.com): Under More Settings → Domains and Directories for your basic page tracking tag, select the Allow Linker checkbox.
  3. Create a trigger based on the form event. Select url contains A.com as your trigger filter. Add a second filter: "element target contains B.com". Name the trigger "outgoing form from A.com to B.com"
  4. Add a Goole Analytics tag (i.e. Tag Type of Google Analytics or Universal). Select "outgoing form from A.com to B.com" as the trigger. Click continue and in step 3, select the Track Type to Decorate Form. Name it (for example, "GA Form Decorator from a.com to B.com).
  5. Save a version of the container and publish it.

If you are using a separate container for B.com, in the container for B.com

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.
  2. Under More Settings → Domains and Directories for this tag, select the Allow Linker checkbox.
  3. Save a version of the container and publish it.

Form Submits from A.com to B.com (Auto Link Domains)

In the container for A.com

  1. Add a (or edit your existing) basic page tracking tag (i.e. Tag Type of Universal Analytics; Track Type of Page View).
  2. If you are using the same container for A.com and B.com, under Fields to Set, enter:
    Field Name: allowLinker
    Value: true
  3. Find the field More settings → Cookie Configuration → Cookie Domain and enter "auto" (no quotes).
  4. Find the field More settings → Cross Domain Tracking → Auto Link Domains and enter "B.com" (no quotes).
    If you have multiple domains, separate them by commas:
    A.com, B.com, C.com
  5. Set the trigger to "All Pages".
  6. Save a version of the container and publish it.

If you are using a separate container for B.com, in the container for B.com

  1. Add a (or edit your existing) basic page tracking tag (i.e. Tag Type of Universal Analytics; Track Type of Page View).
  2. Under Fields to Set, enter:
    1. Field Name: allowLinker
    2. Value: true
  3. Save a version of the container and publish it.

Creating a Trigger for more than two domains

If the trigger for your Decorate Link or Decorate Form tag needs to work for multiple domains, one of which may be the current domain, create a custom JavaScript variable called is cross domain:

function() {
  var domains = ['a.com', 'b.com', 'c.com', 'd.com'];
  var linkHost = {{element}}.hostname || '';
  if (linkHost != '' && linkHost != document.domain) {
    for (var i = 0; i < domains.length; i++) {
      if (linkHost.indexOf(domains[i]) >= 0) return true;
    }
  }
  return false;
}

Then, create your link click trigger filter as follows:
is cross domain equals true

Setting up referral exclusions

To ensure referral data is reported correctly, you should add your cross linked domains to the referral exclusion list in Google Analytics. Read Google Analytics referral exclusions to learn more.

Was this article helpful?
How can we improve it?