+44 7727 978782
ua
Submit Request
15 November | 2021

How to setup cross-domain tracking in Google Analytics 4

Max Zakhozhiy| 31| 0

Cross-domain tracking on Google Analytics 4

Cross-domain tracking in UA is something you’re probably familiar with. Most configurations are done at the code level (e.g. In gtag.js or in GTM(GA tags). Many web analysts and marketers were confused by this confusion. Cross-domain tracking on Google Analytics 4 is much easier.

This guide will demonstrate how to set up cross-domain tracking in Google Analytics 4. We’ll first discuss the problem that cross-domain tracking solves, then we’ll move on to the actual configuration.

You don’t need an introduction? Jump to the configuration

If you’re already familiar with cross-domain tracking, then you can jump to this section. I’ll show you how to set it up in Google Analytics 4.

If you’re new to the subject, keep reading.

Multiple domains: The problem

This will make it very simple.

Google Analytics automatically tracks users using first-party cookies. When you land on a website, GA stores a “ga” cookie. Actually, GA stores more cookies but we will focus on the _ga that is stored in the visitor’s browser with some random identifier. Google Analytics monitors the cookie values as you navigate to pages A and B on your website.

GA knows that the cookie is still there (and the value is the same), so the second page view is included in the same session as the first page.

That’s awesome! You can use web analytics tools (not just GA) to track visitors’ usage of your website and what they are doing. Cookies, as technology have many drawbacks and are not perfect. Let’s just leave this topic for another blog.

Where is the problem?

Due to cross-domain policy, first-party cookies (created for your website) can’t be shared between different domains. Google Analytics on domainB.com won’t be able to recognize that a visitor is coming from domainA.com.

Google Analytics on domain A cannot reach certain cookies from domain A so it creates new cookies.

What is the result? Google Analytics (and other cookie-based web analytics tracking tools), will view you as two separate visitors on the domainA.com, and the domainB.com.

This is a huge problem. In your GA reports, will show too many users. Each person who visits domainA.com, as well as domainB.com, will become two users.

You can also track a new user and a session will start. In your traffic acquisition reports, you will see your domainA.com. This is known as “self-referral”.

cross-domain tracking

What should you do? Track across domains.

What is cross-domain tracking with Google Analytics 4?

It is a workaround that allows webmasters/marketers/analysts to send user’s/visitor’s identifiers from domain A to domain B and preserve the session information. This allows the visitor to be tracked across multiple websites/domains.

Both websites must use the same GA4 property in order to make this work.

cross-domain tracking

What is cross-domain tracking in Google Analytics 4?

This is the complete process.

Google Analytics 4 will send a special parameter to domainB.com when a visitor navigates between domainA.com and domainB.com. The GA on domainB.com can update Google Analytics 4 by using this parameter. It will also be able to understand that there is only one person who is navigating between two websites.

Google Analytics will track subdomains

Yes. You don’t need cross-domain tracking to do that.

You can track multiple websites belonging to the same domain, such as blog.yourwebsite.com. blog.yourwebsite.com and www.yourwebsite.com), Google Analytics 4 will handle that automatically.

If you search for “is subdomain considered cross-domain?” the result is NO.

How do you configure cross-domain tracking within Google Analytics 4

Okay, now that you have a better understanding of the problem and the solution, it is time to set it up.

Remember to follow one rule before you start: both websites (that are included in cross-domain tracking), must have the SAME GA4 property. You can either install the code directly on your site (tag), or via GTM. It is important to do this in the same property.

Step 1. Navigate to the Administration of Google Analytics > Data streams and choose a web data stream.

cross-domain tracking

Step #2. Go to More Tagging Settings.

cross-domain tracking

Step #3. Click Configure your domains.

how to set up a domain in google analytics

Step 4. Enter all domains to be included in the cross-domain tracking setup. Save the file.

how to set up cross-domain tracking google analytics finish

That’s all. This is all you need. GA will take care of that.

Note: If you run Universal Analytics on a website, you must remember something. Both GA versions share the _ga cookie. Your cross-domain configuration in Google Analytics 4 admin must match the settings for Universal Analytics. This means that the domains used in both configurations should match.

This will also impact your automatic outbound clicking tracking in enhanced Measurement. You will no longer be treated as an outbound click for domains you enter here.

Check the setup

After saving your changes, wait a while and then go to domainA.com. You will need to create a link on that website that redirects the visitor to domainB.com.

Click it. After you have been redirected to the second domain, verify the URL. You should include the _gl= parameter and a lot of other stuff.

second domain check

You can then enable the GA Debugger extension, and go to the DebugView section of Google Analytics 4. Once you’ve done that, you can find your device in the a href=”https://www.analyticsmania.com/post/debugview-in-google-analytics-4/”>DebugView section of Google Analytics 4. In some cases, page_location parameter may contain the domainA.com. In other cases, it will contain domainB.com.

This is what you should be looking at.

Remember the redirects

DomainB.com URLs that do not contain _gl parameters might have a JavaScript redirect. To identify issues, use the extension Redirect path.

After installing the plugin, go to domainA.com to click on the link to domainB.com. Click on the Extension Redirect Path to check if the parameter _gl was present. You should contact your developers to verify that it was there at first. This is where you want to keep the _gl parameter.

errors in domain redirection

Questions frequently asked

Although some of these questions are already answered in the blog post, I will list them here because not everyone reads every sentence. Here’s the TL-DR version.

 

What is cross-domain tracking with Google Analytics 4?

It is a workaround that allows webmasters/marketers/analysts to send user’s/visitor’s identifiers from domain A to domain B and preserve the session information. This allows the visitor to be tracked across multiple websites/domains.

 

Why is cross-domain tracking important?

It is essential to ensure that your visitors are accurate and increase in number. The number of sessions will also increase as the visitor navigates to a second domain. A new session will be initiated (because GA considers this a different user).

Is cross-domain tracking necessary for subdomains

If you’re referring to subdomains of the domain, no. Google Analytics 4 (and earlier versions) can track visitors across subdomains. You don’t need any extra configuration.

What do I need to do to set up the referral exclusion for cross-domain tracking with Google Analytics 4

No. Google Analytics 4 automatically handles self-referrals based on domains you have entered in the section “Configure Your Domains” ( source). Referral exclusion lists are required for things such as payment gateway domains.

How can I test cross-domain tracking?

Click the link on the first site to verify cross-domain setup. It will redirect you to the second site. The URL of the second website must contain the _gl= parameter. You can also check the _ga cookie to confirm.

Check both domains using the screenshot below. Both domains must have the same _ga cookie value. Keep an eye on “Domain” in the cookie list.

testing interagency tracking

Google Analytics 4 Cross Domain Tracking – Final words

Cross-domain tracking in GA4 is easier than Universal Analytics. There is no allowLinker nor Auto Link domains.

Go to the administrator of your GA4 property >Data streams and set up your domains in Web Stream.

Google Analytics 4 is clearly showing the direction Google is heading: less configuration in code or GTM and more in the GA4 interface. However, this does not mean that GTM is no longer necessary. Google Tag Manager is still necessary for many purposes.

15 November 2021| Max Zakhozhiy| 31| 0
[addtoany]

ARE YOU READY TO IMPROVE YOUR PROJECT WITH #UAATEAM?

We will be happy to discuss your project, along with your main goals and objectives. You can schedule a meeting with one of our managers.

Open->
to new

Start working with #UAATEAM

  • United States+1
  • Afghanistan (‫افغانستان‬‎)+93
  • Albania (Shqipëri)+355
  • Algeria (‫الجزائر‬‎)+213
  • American Samoa+1
  • Andorra+376
  • Angola+244
  • Anguilla+1
  • Antigua and Barbuda+1
  • Argentina+54
  • Armenia (Հայաստան)+374
  • Aruba+297
  • Australia+61
  • Austria (Österreich)+43
  • Azerbaijan (Azərbaycan)+994
  • Bahamas+1
  • Bahrain (‫البحرين‬‎)+973
  • Bangladesh (বাংলাদেশ)+880
  • Barbados+1
  • Belarus (Беларусь)+375
  • Belgium (België)+32
  • Belize+501
  • Benin (Bénin)+229
  • Bermuda+1
  • Bhutan (འབྲུག)+975
  • Bolivia+591
  • Bosnia and Herzegovina (Босна и Херцеговина)+387
  • Botswana+267
  • Brazil (Brasil)+55
  • British Indian Ocean Territory+246
  • British Virgin Islands+1
  • Brunei+673
  • Bulgaria (България)+359
  • Burkina Faso+226
  • Burundi (Uburundi)+257
  • Cambodia (កម្ពុជា)+855
  • Cameroon (Cameroun)+237
  • Canada+1
  • Cape Verde (Kabu Verdi)+238
  • Caribbean Netherlands+599
  • Cayman Islands+1
  • Central African Republic (République centrafricaine)+236
  • Chad (Tchad)+235
  • Chile+56
  • China (中国)+86
  • Christmas Island+61
  • Cocos (Keeling) Islands+61
  • Colombia+57
  • Comoros (‫جزر القمر‬‎)+269
  • Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)+243
  • Congo (Republic) (Congo-Brazzaville)+242
  • Cook Islands+682
  • Costa Rica+506
  • Côte d’Ivoire+225
  • Croatia (Hrvatska)+385
  • Cuba+53
  • Curaçao+599
  • Cyprus (Κύπρος)+357
  • Czech Republic (Česká republika)+420
  • Denmark (Danmark)+45
  • Djibouti+253
  • Dominica+1
  • Dominican Republic (República Dominicana)+1
  • Ecuador+593
  • Egypt (‫مصر‬‎)+20
  • El Salvador+503
  • Equatorial Guinea (Guinea Ecuatorial)+240
  • Eritrea+291
  • Estonia (Eesti)+372
  • Ethiopia+251
  • Falkland Islands (Islas Malvinas)+500
  • Faroe Islands (Føroyar)+298
  • Fiji+679
  • Finland (Suomi)+358
  • France+33
  • French Guiana (Guyane française)+594
  • French Polynesia (Polynésie française)+689
  • Gabon+241
  • Gambia+220
  • Georgia (საქართველო)+995
  • Germany (Deutschland)+49
  • Ghana (Gaana)+233
  • Gibraltar+350
  • Greece (Ελλάδα)+30
  • Greenland (Kalaallit Nunaat)+299
  • Grenada+1
  • Guadeloupe+590
  • Guam+1
  • Guatemala+502
  • Guernsey+44
  • Guinea (Guinée)+224
  • Guinea-Bissau (Guiné Bissau)+245
  • Guyana+592
  • Haiti+509
  • Honduras+504
  • Hong Kong (香港)+852
  • Hungary (Magyarország)+36
  • Iceland (Ísland)+354
  • India (भारत)+91
  • Indonesia+62
  • Iran (‫ایران‬‎)+98
  • Iraq (‫العراق‬‎)+964
  • Ireland+353
  • Isle of Man+44
  • Israel (‫ישראל‬‎)+972
  • Italy (Italia)+39
  • Jamaica+1
  • Japan (日本)+81
  • Jersey+44
  • Jordan (‫الأردن‬‎)+962
  • Kazakhstan (Казахстан)+7
  • Kenya+254
  • Kiribati+686
  • Kosovo+383
  • Kuwait (‫الكويت‬‎)+965
  • Kyrgyzstan (Кыргызстан)+996
  • Laos (ລາວ)+856
  • Latvia (Latvija)+371
  • Lebanon (‫لبنان‬‎)+961
  • Lesotho+266
  • Liberia+231
  • Libya (‫ليبيا‬‎)+218
  • Liechtenstein+423
  • Lithuania (Lietuva)+370
  • Luxembourg+352
  • Macau (澳門)+853
  • Macedonia (FYROM) (Македонија)+389
  • Madagascar (Madagasikara)+261
  • Malawi+265
  • Malaysia+60
  • Maldives+960
  • Mali+223
  • Malta+356
  • Marshall Islands+692
  • Martinique+596
  • Mauritania (‫موريتانيا‬‎)+222
  • Mauritius (Moris)+230
  • Mayotte+262
  • Mexico (México)+52
  • Micronesia+691
  • Moldova (Republica Moldova)+373
  • Monaco+377
  • Mongolia (Монгол)+976
  • Montenegro (Crna Gora)+382
  • Montserrat+1
  • Morocco (‫المغرب‬‎)+212
  • Mozambique (Moçambique)+258
  • Myanmar (Burma) (မြန်မာ)+95
  • Namibia (Namibië)+264
  • Nauru+674
  • Nepal (नेपाल)+977
  • Netherlands (Nederland)+31
  • New Caledonia (Nouvelle-Calédonie)+687
  • New Zealand+64
  • Nicaragua+505
  • Niger (Nijar)+227
  • Nigeria+234
  • Niue+683
  • Norfolk Island+672
  • North Korea (조선 민주주의 인민 공화국)+850
  • Northern Mariana Islands+1
  • Norway (Norge)+47
  • Oman (‫عُمان‬‎)+968
  • Pakistan (‫پاکستان‬‎)+92
  • Palau+680
  • Palestine (‫فلسطين‬‎)+970
  • Panama (Panamá)+507
  • Papua New Guinea+675
  • Paraguay+595
  • Peru (Perú)+51
  • Philippines+63
  • Poland (Polska)+48
  • Portugal+351
  • Puerto Rico+1
  • Qatar (‫قطر‬‎)+974
  • Réunion (La Réunion)+262
  • Romania (România)+40
  • Russia (Россия)+7
  • Rwanda+250
  • Saint Barthélemy+590
  • Saint Helena+290
  • Saint Kitts and Nevis+1
  • Saint Lucia+1
  • Saint Martin (Saint-Martin (partie française))+590
  • Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)+508
  • Saint Vincent and the Grenadines+1
  • Samoa+685
  • San Marino+378
  • São Tomé and Príncipe (São Tomé e Príncipe)+239
  • Saudi Arabia (‫المملكة العربية السعودية‬‎)+966
  • Senegal (Sénégal)+221
  • Serbia (Србија)+381
  • Seychelles+248
  • Sierra Leone+232
  • Singapore+65
  • Sint Maarten+1
  • Slovakia (Slovensko)+421
  • Slovenia (Slovenija)+386
  • Solomon Islands+677
  • Somalia (Soomaaliya)+252
  • South Africa+27
  • South Korea (대한민국)+82
  • South Sudan (‫جنوب السودان‬‎)+211
  • Spain (España)+34
  • Sri Lanka (ශ්‍රී ලංකාව)+94
  • Sudan (‫السودان‬‎)+249
  • Suriname+597
  • Svalbard and Jan Mayen+47
  • Swaziland+268
  • Sweden (Sverige)+46
  • Switzerland (Schweiz)+41
  • Syria (‫سوريا‬‎)+963
  • Taiwan (台灣)+886
  • Tajikistan+992
  • Tanzania+255
  • Thailand (ไทย)+66
  • Timor-Leste+670
  • Togo+228
  • Tokelau+690
  • Tonga+676
  • Trinidad and Tobago+1
  • Tunisia (‫تونس‬‎)+216
  • Turkey (Türkiye)+90
  • Turkmenistan+993
  • Turks and Caicos Islands+1
  • Tuvalu+688
  • U.S. Virgin Islands+1
  • Uganda+256
  • Ukraine (Україна)+380
  • United Arab Emirates (‫الإمارات العربية المتحدة‬‎)+971
  • United Kingdom+44
  • United States+1
  • Uruguay+598
  • Uzbekistan (Oʻzbekiston)+998
  • Vanuatu+678
  • Vatican City (Città del Vaticano)+39
  • Venezuela+58
  • Vietnam (Việt Nam)+84
  • Wallis and Futuna (Wallis-et-Futuna)+681
  • Western Sahara (‫الصحراء الغربية‬‎)+212
  • Yemen (‫اليمن‬‎)+967
  • Zambia+260
  • Zimbabwe+263
  • Åland Islands+358
Select a Service:
Please fill in all required form fields