Marketing toolsSEO

A Complete Cross-Domain Tracking Guide 2019

Cross-Domain-Tracking

Source: digishuffle

Cross-domain tracking is the process of measuring two related or different websites as one.

Image source: Google Support

Why you need Cross-Domain Tracking Measurement?

Example:  if you have a website semupdates.com and your blog is on blog.semupdates.com. Or you have multiple microsites like services.semupdates.com etc.

Challenge: When a user visits your main website semupdates.com and click on the blog tab. Google Analytics lose the path of that session and session gets terminated. Disadvantage: of it would be – You will get the wrong data, which lead to the wrong decision. Your website bounce rate will increase. The content updated on the blog site won’t help you getting any SEO benefits.

Solution: But if you put the cross-domain tracking in place, you will be able to get accurate data. You can track the visitors landing to your site and running through the blog section or any other section on your website or other microsites.

How to Implement Cross-Domain Tracking for Two Different Websites?

To implement cross-domain tracking successfully, you must have the knowledge and HTML & Javascript, or you would need a web developer for that.

Create a single property in your Google Analytics account. Now, you will have to use the same ID on both sites which you would like to link. You have to make a few updates in your Analytics code.

  1. Go to the Analytics -> Admin -> Tracking info – > Tracking code
  2. Copy this tracking code in the text file before making changes in the code
  3. Make a copy of that file to make the changes, so you can check the changes later.

There are two methods to do it:

  1. Google Tag Manager
  2. Manually adding code on both sites

Google Tag Manager:

Google Tag Manager is a tool by Google helps you implement multiple tracking codes on the website without any code updates on the website.

  1. Create a Google Tag Manager account with same google id by which you created Analytics account.
  2. Setup the container in Google Tag Manager – > Then move the main dashboard

Follow the instructions to implement cross-domain tracking through GTM:

First, go to the variables section and navigate to GA variable you have created previously on GTM for Analytics tracking. Variables are created on the data layers, so once you make any changes to this, it will automatically reflect all the tags created using this variable.

Google Tag Manager - variable - GA

 

Enter your cookie domain which is your main domain/source domain. Then click on the ‘More Settings’ option.

 

Google Tag Manager 0 Variables - 3

Then you will see the ‘Cross-domain tracking’ option in the drop-down menu. Expand all the fields

Cross-domain-linking - 4

 

Fill up all the required fields under the ‘Cross Domain Tracking’ menu. Add all the domain which you would like to link with your main domain in this field ‘Auto Link Domains’. Do not make any changes to the remaining fields.

enter linking domain - 5

Then scroll up in the ‘More Settings’ drop-down menu and follow the procedure numbered below:

  1. Click on ‘Field to set’
  2. Select the ‘allowLinker’ option from the dropdown
  3. Add ‘true’ in the ‘Value’ field
  4. Click on the ‘Save’ button at the top right corner
  5. Publish the container and you are done!

 

More Settings

 

Manually Adding the code on Both Sites

To manually add the code on the site, you have to extract code from your analytics account as per the given instructions in the beginning. To link both sites code manually you have to establish a linker between them.

Establish Linker between the sites

  1. By using analytics.js
  2. By using gtag.js

By using analytics.js:

Find the create a line in the snippet. For a website called example-1.com, it looks like this:

ga(‘create’, ‘UA-XXXXXXX-Y’, ‘example-1.com’);

Make the following changes to the snippet (the changes you need to make are in bold red text):

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

Remember to replace the example Google Analytics ID (UA-XXXXXX-Y) with your own ID, and replace the example secondary domain (example-2.com) with your own secondary domain name.

For three or more domains

Follow the example above, but add the other domains to the autoLink plugin. Even the additional comma here is important:

ga(‘linker:autoLink’, [‘example-2.com’, ‘example-3.com’] );

 

By using gtag.js

Your original gtag.js looks like this, when you copy it from your analytics account.

<!– Global site tag (gtag.js) – Google Analytics –>

<script async src=”https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X”></script>

<script>

window.dataLayer = window.dataLayer || [];

function gtag(){dataLayer.push(arguments);}

gtag(‘js’, new Date());

 

gtag(‘config’, ‘UA-XXXXXXXX-X’);

</script>

On the main domain, make the following changes:

<script async src=”https://www.googletagmanager.com/gtag/js?id=GA-TRACKING_ID”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘set’, ‘linker’, {‘domains’: [‘example.com’]});
gtag(‘js’, new Date());

gtag(‘config’, ‘GA-TRACKING_ID’);
</script>OR you can can put this way:

gtag(‘config’, ‘GA_tracking_ID’, {
‘linker’: {
‘domains’: [‘example.com’]
}
});

On the sub-domain of the other site, make the following changes in gtag.js

gtag(‘config’, ‘GA_tracking_ID’, {
‘linker’: {
‘accept_incoming’: true
}
});

Bi-directional cross-domain tracking

On source.com, update the property’s config:

gtag(‘config’, ‘GA_tracking_ID’, {
‘linker’: {
‘domains’: [‘example-destination.com’]
}
});

On destination.com, update the property’s config:

gtag(‘config’, ‘GA_tracking_ID’, {
‘linker’: {
‘domains’: [‘example-source.com’]
}
});

Using a single snippet on all domains

On example-1.com, update the property’s config:

gtag(‘config’, ‘GA_MEASUREMENT_ID_1’, {
‘linker’: {
‘domains’: [‘example-1.com’, ‘example-2.com’]
}
});

On example-2.com, update the property’s config:

gtag(‘config’, ‘GA_MEASUREMENT_ID_2’, {
‘linker’: {
‘domains’: [‘example-1.com’, ‘example-2.com’]
}
});

Challenge:

Once you are done with code placements, Analytics will be able to gather data from both sites and will combine it in one view. Then the challenge would be to figure out – which domain are they visiting?

For example – In the site content report you will see:

/contact

/about-us

Domain names are not visible in these reports. So, how will you decide which domain this page belongs to?

Solution:

  1. Go to the Admin section of your analytics account
  2. Create a new view to applying various filters, so that you will have a backup view
  3. Once you created the view, then go to the advanced filter at the view level

Analytics - 7

  1. Click on the filters -> custom filtercustom-filters
  2. When you click on the ‘Custom’ filter You will see various types of filters below. Select ‘Advance’. Fill up the fields as mentioned below and Save the filter:
    1. Field A –> Extract A: Hostname = (.*)
    2. Field B –> Extract B: Request URI = (.*)
    3. Output To –> Constructor: Request URI = $A1$B1

Challenge:

When you visit sites one from another, analytics shows the data in ‘Referral traffic’ and then create a new session. So, this is not the correct way to get accurate data.

Solution:

To make these visits as a single session across multiple domains, you have to create a referral exclusion list. Follow the instructions to do that:

  1. Go to the admin section in your analytics account
  2. Click on ‘Tracking Info’ in ‘Property’ tabReferral exclusion list creation -10
  3. Click on the ‘+ ADD REFERRAL EXCLUSION’ button and enter the domain which you don’t want to see in referral traffic source section in the reporting. Then click on the ‘Create’ button.referal exclusion list - 11

To check if all the settings you have done for cross-domain tracking is correct, please run through ‘Google Tag Assistant’ recording:

  1. Install ‘Google Tag Assistant’ chrome extension.
  2. Open your website, then click on the GTA icon in the browser. Then click on Record, and later you can view the recording it the cross-domain tracking working fine.google-teg-manager-sem

Google updates their tools, really frequently. These guides are updated as per the recent changes Google in their code and tools. Hope it will be helpful for you. If I missed something, or if you have any feedback or suggestion, please feel free to comment.

About author

Richa Pathak is a product marketing consultant having 5+ years of industry experience. She has contributed more than 25 firms around the world, & advised ahandful of startups to grow. She writes about product marketing, event promotion, digital marketing, social media, content marketing, email marketing, and advertising. You can connect with her on the Facebook, Twitter, and LinkedIn.