Cross-domain tracking is the process of measuring two related or different websites as one.
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?
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.
Make a copy of that file to make the changes, so you can check the changes later.
Google Tag Manager is a tool by Google helps you implement multiple tracking codes on the website without any code updates on the website.
Create a Google Tag Manager account with same google id by which you created Analytics account.
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.
Enter your cookie domain which is your main domain/source domain. Then click on the ‘More Settings’ option.
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.
Publish the container and you are done!
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.
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.
Your original gtag.js looks like this, when you copy it from your analytics account.
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?
Domain names are not visible in these reports. So, how will you decide which domain this page belongs to?
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.
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.
Install ‘Google Tag Assistant’ chrome extension.
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 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.