How to implement Cross domain tracking on Universal Analytics

Installing Google Analytics on your site is the basic, you already know. But did you know that in some cases, just copying and pasting your tag is not enough. One or more additional configurations may be necessary. The case I will present in this article will be configuring Google Analytics to track data on multiple domain names. This is called cross-domain tracking.

Does your site need to cross domain tracking?

What is a domain?

If you already know the difference between a subdomain and a domain, you can skip this paragraph.

A URL is composed of a subdomain, a domain, and a top-level domain or TLD. In the case of my URL, www.melanie-almeida.com :

  • www is the subdomain
  • melanie-almeida the domain
  • .com the TLD

If my site contains the URLs https://video.melanie-almeida.com and https://blog.melanie-almeida.com, then my site has two different subdomains. It is not necessary to configure Google Analytics tracking on subdomains.
But if my site redirects to www.melanie-almeida.com and www.melanie-almeida.fr, the URLs have the same domain name, but two different TDLs. You have to consider them as two different domains and apply cross-domain tracking.

Some common cases where cross domain tracking is essential:

You have a subscription or e-commerce site and your sales page is hosted on a partner site like stripe or paypal.
Your users go from a landing page hosted on a platform like landen or instapage before arriving on your site. But, you haven’t set up a custom url for your landing pages.

Here is a graph that will help you to know if you need to set up cross domain tracking or not:

cross-domain-flow-chart
Source: www.bounteous.com

Why configure cross domain tracking?

For this part, the Google Analytics blog gives the best explanation:

In order to track sessions, Analytics collects the Client-ID value on each call. Client-ID values are stored in cookies. Cookies are stored on a per-domain basis, and websites in one domain do not have access to cookies set for another domain. When sessions are tracked across multiple domains, the Client-ID value must be transferred from one domain to another. To accomplish this, the Analytics tracking code includes link functions that allow the source domain to place the Client-ID in the URL parameters of a link. This allows the destination domain to access the Client-ID.

In practical terms, if your users navigate between your domain and another domain name, part of the user journey will be lost. If the user returns to your main domain name, his visit will be counted as a second session, even if it took place in the same session. To conclude, cross domain tracking allows Google Analytic to group sessions from two sites into one session, even if the domain name is different.

How to do it with Google Tag Manager?

On your Google Tag Manager, I must modify your Google Analytics variable already installed.

In fields set, I have to add the field allowLinker with the value: true. Then in the Cross Domain Tracking settings, I have to add the related domain name(s). If there are several domain names, separate them with a comma.

This is what your variable will look like:

variable ga cross domain tracking

Meanwhile, you need to add your Google Analytics tracking code on the other domain name that is not yours. Most partner sites offer a Google Analytics integration that allows you to add your tracking code.

How to do it by modifying directly the tracking code?

If you don’t have Google Tag Manager (which I don’t recommend), you can do this configuration directly in the tracking code.

Here is what it will look like if you add allowLinker and the 2nd domain name:

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['example-2.com'] );

Then edit the second domain to include the tracking code for your primary domain. As mentioned earlier, some partner sites include a place to add your tracking code.

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['example-1.com'] );

Remember to replace the example tracking ID (UA-XXXXXX-Y) with your tracking ID, and the example main domain (example-1.com) with your main domain name.

In case the second domain brings traffic to your site, you should exclude it from your referral sites. If you don’t do this, there will be two sessions counted, instead of one.

For example, in my case, I created a landing page that sends traffic to my site. These two sites have two different domains, I have installed my cross domain tracking configuration, the sessions of these two sites will be present on my Google Analytics. However, I would like them to be counted as one session so that my total sessions are not inflated. So, I exclude the first domain name of the referring sites. My landing page will not be counted as a referral, but as if it were my site.

To exclude a site from the referral sites:

  1. Log in to your Analytics account.
  2. Click on Admin.
  3. In the ACCOUNT column, select the Analytics account that contains the desired property.
  4. In the PROPERTY column, select a property.
  5. Click on Tracking Information.
  6. Click on Referrer Exclusion List.
  7. To add a domain, click + Add Referrer Exclusion.
  8. Enter the domain name.
  9. Click Create to save the change.

See screenshot below:

google-analytic-exclusion de sites référents

Display domain names on your reports

By default, on Google Analytics, you will only see the page path and name, not the domain name. As a result, it can be difficult to track the performance of different domain names and the behavior of users on those domain names.

But it is possible to reveal the domain names in your reports with an additional configuration in your ADMIN.

Let’s create a copy of your reports view with the data of each of your domains and add a filter. In this filter, you add the following settings:

  • Filter Type: Custom Filter > Advanced
  • Field A -> Extract A: Host name = (.*)
  • Field B -> Extract B: URI of the request = (.*)
  • Output to -> Builder: URI of the request = $A1$B1

Finally, for all these manipulations, remember to perform tests to verify that everything works correctly. Therefore, please keep in mind if you use Google Tag Manager to activate the PREVIEW feature to test. And, to navigate on your different domain names with the Tag Assistant.


Posted

in

by

Comments

Leave a Reply

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