+44 7445 523468
ua
Submit Request

How to setup cross-domain tracking in Google Analytics 4

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.

Google Analytics 4: What you need to know about the new analytics

Google Analytics 4: What you need to know about the new analytics

When the button for switching to the GA4 resource appeared in the Google Analytics interface, everyone abruptly started discussing this topic, though the “App and Site” resources were available long ago. Everyone was just sure that it was necessary only for those ones who have both an app and a website.

First of all, you shall take into account the following:

Universal resources are still alive, it is better to use them together with GA4. When creating a new resource, you can select both types. Why you should not completely switch to the new type:

  • Since the tool is new, not all functions work perfectly yet, and there can be occasional failures.
  • If you use integration with services, in most cases it is not yet adapted to the resources of this type.
  • Not all functions are available yet, they are added step-by-step.
  • If the previous version of analytics was based on the page view, the new version is based on events and their parameters. Therefore, some indicators have disappeared.
  • There are no views in this version. There is an account, a resource, and data streams.

In general, the analytics is more user-friendly than previous versions. More flexible settings, fewer unnecessary actions, very convenient tools for insights and smart search. Now let’s look at the main changes

EVENT TRACKING.

This is the main fundamental change in the new type of resources. Since the analytics is based on the events, a number of changes have been made. The types of referencing are not registered and are recorded as an event. Example of differences from the official help information.

Events no longer have a “category, action, label” structure. Parameters are registered for events.

There are 3 types of events: automatic (registered without additional configuration), recommended (these are also standard events, but you need to configure their tracking), and special (user events that you create yourself). You can add up to 500 of the latter, so before configuration you shall check the following: whether the events you need are registered automatically.

Have a look at the “improved statistics” tool at the link. You can also create and modify events based on their parameters. The question often arises how to transfer e-commerce from UA to GA4. The help has a detailed article about the differences.

ANALYSIS TOOL

This tool gives a huge advantage to the new analytics over the previous version. I think most users regularly have to face the need constantly to create custom reports, sometimes just to change a bit the set of indicators in a standard report. This is very inconvenient. Here you can create very flexible reports much faster, there is a gallery of ready-made solutions.

In order to use the ready-made templates, you need to go to the gallery.

INTEGRATIONS

In the new version, integration with Big Query is available. In UA, it was paid, but here it is free. There is also a more functional interaction of data from all Google services. For example, the “interested (engaged) view” conversion is available on YouTube.

For the present the third-party services and CMS are the main problem, not everyone has a ready-made integration. Therefore, if it is possible to make changes directly into the code, it is recommended to use this feature. For now, these issues should be actively monitored. In the help there is an article about transfer for CMS. Also at the time of writing of the article, there are instructions for connection on certain platforms:

  • Blogger
  • GoDaddy
  • Google Sites
  • Magento
  • Shopify
  • SquareSpace
  • Weebly
  • Wix
  • WordPress

You can see here how data import works. For the present we are waiting for the feature that will make it possible to import data on expenses from third-party systems.

DATA FILTERING, EXCLUSION OF TRAFFIC SOURCES, AND ATTRIBUTION (MOST POPULAR QUESTIONS)

There are much fewer filters in GA4 than in the previous version. There are no views in the analytics, so there arises a question about data filtering. It is possible that in the future it will be possible to open access to data streams, but for the present there is no analog for access to the view.

Filters that are available:

Google offers to replace the remaining filters with a comparison tool and event conversion. The feature of exclusion of traffic sources has already been added to the settings.

For attribution, Google recommends using the settings in the reports. When you import a conversion to an Advertisement, you can use only the last click attribution model, and maybe, it will be possible to change this after a some time.

ADVANTAGES

  1. Flexible configuration and user-friendly interface. In addition to the analysis and additional changes that you can make in each report, you shall pay attention to computer-aided instructions and NLP functions. Convenient hints, search and forecasts. A lot of unnecessary things are removed and the missing ones are added.
  2. The feature that allows more accurately to predict performance and create an audience based on the forecasts. It is also possible thanks to the computer-aided instructions.
  3. Convenient cross-platform tracking.
  4. More accurate tracking, that is based on device and user IDs (can also be configured), data security.
  5. Integrations

 

CONCLUSION

There are discussions in the Internet already for a long time about the fact that sooner or later everyone will have to switch for 100% to the new analytics. And the earlier it is installed, the more data will be collected, therefore, if there is such a possibility, it is better to integrate it now and use it in parallel with the UA and study it at a comfortable pace. Yes, the tool is new, many functions are being added for the present, but now it is actively worked on, you need to track the system news on the link.

Open->
to new

Start working with #UAATEAM

Select a Service: