Skip to content

A Beginner’s Guide to Cross-Domain Tracking & Setup

In Google Analytics, the process of Cross-Domain Tracking refers to the ability to track a contiguous single Session between two or more top-level Domains. This article will discuss the basics of Google Analytics Sessions and how to set up Google Tag Manager for Cross-Domain Tracking.

Google Analytics – Client ID and Sessions

When tracking a Session, Google Analytics creates an identifier (the Client ID) and persists that identifier in a browser cookie.

If you’re on a website that is running Google Analytics, you’ll see the Client ID identifier for your Session persisted in the _ga cookie:

All browsers operate under a principle known as the Same-Origin Policy. To summarize, this means that browser cookies are only able to be read and used on the same domain on which it was created. A cookie that is created on one domain cannot be used on another.

If you are attempting to track user Sessions on multiple domains using the same Google Analytics account, a process must be used so that this Client ID is maintained in cookies set on both domains.

An Important Note With Respect to Subdomains

The Same-Origin Policy applies to domains, not subdomains.  Cookies (including the _ga Client ID cookie) can be read and used by any subdomain of the domain that set the cookie. If you visit a subdomain as part of a Google Analytics Session, the Client ID will be the same — it will still consider your session to be active within that domain.

So if you browse from mysite.com to blog.mysite.com, you never left mysite.com from a Same-Origin Policy perspective, and your Session will be tracked under the same Client ID assuming the same Google Analytics account is running.

We don’t want a new Session to be created every time a user goes from one domain to another one. Without Cross-Domain tracking set up, you may have some difficulty trying to track into a single reporting view a Conversion or a Transaction from beginning to end.  If not set up correctly, you will not be able to track the entire user journey and its related channel and conversion data.

Q: What is a Session in Google Analytics?

A Session to Google Analytics is a sequence of tracked activity that’s associated with a User.

It’s a group of interactions, both with respect to Page Views and Conversion Events that a User takes within a given time period.

For example, below we see a sequential journey of a User navigating from a Category page to a Product page, and then to Checkout, finally leading to an Order Confirmation page.

Once the User leaves the site, the Page Views and Events associated with the site activity are associated with the corresponding Client ID and referred to as a Session.  Each Session in Google Analytics is referenced by its own unique Client ID value.

If you install a browser plugin such as Google Tag Assistant, you can use the Record feature to observe the Google Analytics Activity relative to a Session as you navigate your site, as seen in the example below:

Inactivity Time Impacts Sessions

Inactivity is the time interval between hits to Google Analytics.  Google Analytics defines a session to end after 30 minutes of inactivity. For instance, if you select something from the product page and then wait for another 30 mins before checking out, Google Analytics will create a new Session on your behalf.

In the example above, given a User that waits 35 minutes before navigating from the /product page to the /checkout page – a new Session would be created, starting at the /checkout page.

(Google Analytics would consider the new Session to be Direct traffic to the /checkout page.)

Google Analytics End Sessions at Midnight

At midnight local time, Google considers every session to end. So if you click on a specific ad at 23:55 for a category or a product page, at midnight, Google resets your session.

Now that we have a basic working definition of how the Google Analytics Client ID is set (Same-Origin Cookie Policy) and how Google Analytics uses the Client ID to define a Session, we can discuss how to maintain the Client ID between multiple domains.

Setting up Google Analytics Cross-Domain Tracking

If you’re deploying Google Analytics through Google Tag Manager, it’s quite easy to set up cross-domain tracking.  The basic steps to take are as follows:

  1. In Google Tag Manager, configure your Google Analytics settings such that the allowLinker field is set.allowLinker is a Google Analytics settings directive which instructs Google Analytics to use the value of the _ga querystring parameter (if present) to set the Client ID cookie for the Session.
  2. In Google Tag Manager, configure your Google Analytics settings such that the Auto Link Domains field is set with a comma-delimited list of domains that should be linked.With both of these two updates Published in Google Tag Manager, Google Tag Manager will detect clicks on any links between those domains and will automatically update the URLs such that they include a _ga querystring parameter – we’ll go over this in more detail further in this article (see “Testing Your Cross-Domain Tracking”).
  3. Update the Referral Exclusion List, adding your different website domains to Google Analytics.
    The referral exclusion ensures you don’t count referrals from certain domains. Any domain in your Auto-Link Domain settings in Google Tag Manager should be in the referral exclusion list for Google Analytics.

Testing Cross-Domain Tracking

To test whether a cross-domain tracking is working, visit the website after you’ve updated Google Tag Manager and Google Analytics, then click one of the links that go from domain to domain.

For example, if you’re on rideengine.com and you click a link to go to blog.slingshotsports.com, you should see a link in the browser that looks like what you see here.

Please note that the URL contains three key pieces of information.

  1. The _ga querystring indicates that the linker has updated the target URL for cross-domain tracking.
  2. Each _ga querystring includes a timestamp hash that is valid for 2 minutes.
    This exists to prevent linker parameters from persisting in shared links and browser history entries.
  3. The Client ID is the identifier for that specific Google Analytics Session.

If you click a link between two domains and you see a URL that looks similar to the one above with a query string and the client id matching between both domains, your session has been handed off successfully, and you have basic cross-domain tracking set up for your Google Analytics account.

Happy tracking!

Have Questions About Cross-Domain Tracking?

We’d be happy to hear from you!