How to set up cross-domain tracking in GA4 (Google Analytics 4)

Google Analytics4 or GA4 is the latest version of Google Analytics.

Google Analytics allows you to integrate mobile app and website usage data into a single GA Property. This new property is called ‘Google Analytics 4 (or GA4)’ and it is available in your GA account when you create a new property.

If you haven’t created your GA4 property yet then you need to create one before you can set up cross-domain tracking. Check out this article for more details: How to upgrade to Google Analytics 4 (GA4)

When it comes to updating your existing analytics property (Universal Analytics) to GA4 or setting up a new analytics property in GA 4, the implementation method is completely new.

In this article, I am going to talk about how to set up cross-domain tracking in Google Analytics 4.

Cross-domain tracking

Cross-domain measurement allows you to uniquely identify your website user across different domains. With cross-domain tracking, activity is attributed to the same user regardless of domain. This helps to keep user counts more accurate and give you a complete view of a user’s journey across domains.

When you set up cross-domain tracking and when an outbound link leads to another domain, the enhanced measurement option to track outbound links is ignored. This allows the same user to be tracked across different domains.

Cookies and cross-domain measurement

Google Analytics uses first-party cookies to identify unique users on the website.

If you have multiple website domains with analytics tracking implemented, GA will create a new cookie every time a user navigates through the website domains. In this case, the same user will have a separate cookie for each of the domains and will be counted as a separate user for each domain.

With cross-domain tracking implemented, when the user navigates to a different domain, analytics cookies are passed from one domain to another using the URL parameter identified as key ‘_gl’. For example, https://optimizesmart.com/?_gl=1*abcde5*

This way you can identify the same user across your domains and get a complete view of the user’s journey.

Setting up cross-domain tracking

In the legacy version of Google Analytics, a complicated set up was required to set up the cross-domain tracking. It was usually done by using the ‘allowlinker’ parameter hardcoded into every single Google Tag Manager tag (if you are using Google Tag Manager) or in every ‘gtag.js’ (Global Site Tag) call.

In the case of Google Analytics 4 setting up cross-domain tracking has been made very simple and no hardcoded tagging is required like in the earlier version. It can now be achieved with only configuration settings in the ‘Admin’ section.

Follow the simple steps below to get started:

Note: You will need edit level access to the GA4 property to set up cross-domain tracking.

Example reference: In the below steps we are setting up cross-domain tracking between two different GA4 properties.

  1. Sample website domain: example.com
  2. Sample website 2 domain: example2.com

Step 1: Navigate to your GA4 Property in Google Analytics. Click on the ‘Admin’ tab available on the left-hand side.

Step 2: A new overlay will appear as below. Click on ‘Data Streams’.

Step 3: Data streams shows you all the available streams (GA4 properties and their details). Select the web property for which you wanted to set up cross-domain tracking. In our case, we will select ‘Sample Website’ with the domain ‘example.com’.

Step 4: An overlay will appear like below. Click on the ‘Tagging Settings’ options under additional settings.

Step 5: A new overlay will appear as below with a variety of features available. As of now, we are focusing on cross-domain tracking so click on the ‘Configure Your Domains’ option.

Step 6: You will see the configuration panel opens up like below.

You will see a really important note at the top. If you are using a legacy version of Google Analytics universal properties and want to set up cross-domain tracking between GA4 and a legacy version then you need to map the settings between each type of property. You can click ‘Learn more’ which will guide you through the required settings.

In our case, we are setting up the cross-domain tracking for GA4 properties and it is going to be simpler. Here we just need to add our domains and, as I said earlier, no hardcoded changes are required.

Just click on ‘Add condition’,

Step 7: You will get the option to select the math type for the domain conditions. You can use any of the following to meet your business needs.

  • Contains: Includes part of a string in the domain name.
  • Begins With: Includes domain which start with a specified string.
  • Ends With: Includes domains which end with a specified string.
  • Exactly Matches: Exactly matches whole part of a domain string.
  • Matches Regex: Powerful lookups to match multiple domains from the list specified.

We will be using a simple match type in our case – ‘contains’.

Step 8: Add the domain like below. We are adding the domain name for sample website 2.

(Match Type: Contains and Domain: example2.com)

Now click on ‘Save’.

Step 9: Now navigate to the data streams tab in the ‘Admin’ section and select another web property. In our case, we will select the domain for sample website 2 – example2.com.

Step 10: An overlay will appear like below. Click on the ‘Tagging Settings’ option under additional settings.

Step 11: Click on the ‘Configure your domains’ option.

Step 12: You will see the configuration panel open up like below. Just click on ‘Add condition’.

Step 13: You will get the option to select the math type for the domain conditions.

We will be using a simple match type in our case – ‘contains’.

Now add the respective domain of the first website in the textbox next to match type. Match Type = Contains and Domain = example.com.

Step 14: Click on ‘Save’.

Congratulations!!! You have successfully configured the cross-domain tracking.

Now the cross-domain setting is done, when the users navigate from one website to another, it will be counted as a single visit and all the traffic sources will be consistent throughout.

Debugging the setup

You can debug the cross-domain tracking functionality in order to validate the setup.

Navigate to any of your websites and click on the link to another domain for which you have configured the cross-domain tracking. Once you click the link you will be redirected to the new domain and you can check the URL will be populated with new ‘_gl’  parameter like below.

If you see the ‘_gl’ parameter in the URL that means your cross-domain tracking is working properly. This ‘_gl’ parameter will continue the session from the previous domain to the new domain and it won’t be treated as a new user.

It will also pass all the GA information it has on the earlier domain, such as traffic source, attribution modelling, and GA cookie values.

Related Articles on GA4 (Google Analytics 4):

  1. What is Google Analytics 4 (GA4) – The Apps + Web Property
  2. How to upgrade to Google Analytics 4 (GA4) 
  3. How to setup enhanced measurement tracking in GA4 (Google Analytics 4)
  4. How to set up event tracking in GA4 (Google Analytics 4)
  5. How to set up conversion tracking in GA4 (Google Analytics 4)
  6. How to connect GA4 (Google Analytics 4) with Google Data Studio
  7. How to connect GA4 (Google Analytics 4) with Google Ads
  8. How to connect GA4 (Google Analytics 4) with BigQuery
  9. Analysis Hub Google Analytics – How to use the Exploration Report in GA4
  10. How to set up Custom Events in GA4 via Google Tag Manager
  11. How to set up site search tracking in GA4
  12. How to set up scroll tracking in GA4
  13. Google Analytics 4 (GA4) vs Universal Analytics – What is the difference?
  14. How To Set Up Ecommerce Tracking in GA4 (Google Analytics 4)
  15. Google Signals for GA4 – How to see gender, interest and age data in Google Analytics 4
  16. How to block internal traffic in GA4 (Google Analytics 4)
  17. How to import conversions from GA4 property to your Google Ads account

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."



Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.



   

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

Himanshu Sharma

Digital Marketing Consultant and Founder of Optimizesmart.com

Himanshu helps business owners and marketing professionals in generating more sales and ROI by fixing their website tracking issues, helping them understand their true customers' purchase journey and helping them determine the most effective marketing channels for investment.

He has over 12 years of experience in digital analytics and digital marketing.

He was nominated for the Digital Analytics Association's Awards for Excellence. The Digital Analytics Association is a world-renowned not-for-profit association that helps organisations overcome the challenges of data acquisition and application.

He is the author of four best-selling books on analytics and conversion optimization:

error: Alert: Content is protected !!