This article is about Google Analytics 4 properties. If you're using a Universal Analytics property, refer to the Universal Analytics section of this help center.

[GA4] Set up cross-domain measurement

This article is for website owners who need unified measurement across more than one domain, e.g. across a customer website and a separate shopping cart domain. This article pertains to Google Analytics 4 properties; if you are using Universal Analytics, read this article instead.

Cross-domain measurement allows activity to be accurately attributed to a single user as they cross domains. Outbound clicks that would ordinarily trigger an event via enhanced measurement are ignored when the outbound link leads to a domain that you've listed as part of cross-domain measurement.

Video overview


Cookies and cross-domain measurement

Analytics uses first-party cookies to set an identifier for each unique user and session to a website.

  • Without cross-domain measurement, new cookies with new identifiers are set for each domain a user visits. Analytics count these new cookies with new identifiers as separate users with separate sessions.
  • With cross-domain measurement, the same identifiers are passed from one site to another via a URL parameter identified by the key _gl:, for example:*abcde5*.

If you also have a Universal Analytics property

For your Universal Analytics property, you configured cross-domain measurement via code (either in the source code through analytics.js or gtag.js, or via Google Tag Manager). For your Google Analytics 4 property, you'll do this via the Admin page. Follow the instructions below to add the same domains you've identified in your Universal Analytics page code.

If you have an existing configuration in the global site tag for your Universal Analytics property, it will be applied to your Google Analytics 4 property as well. Any domains you've specified in the code or via the Admin will apply to your Google Analytics 4 property. However, we recommend that you configure in the Admin only.

Set up cross-domain measurement via the Admin

You need the Editor role to set up cross-domain measurement.

Check the Analytics tag (e.g. the global site tag on each of your HTML pages) for each domain that you want to include in your cross-domain measurement.  The tag on each page must use the same Measurement ID (i.e same. "G-" ID) from the same web data stream.

  1. In Admin, navigate to one of the properties you want to include in cross-domain measurement.
  2. In the Property column, click Data Streams > Web.
  3. Click the data stream for your website, then under Additional Settings, click More tagging settings.
  4. Click Configure your domains.
  5. Under Include domains that match ANY of the following conditions:
    • Choose a match type.
    • Under Domain, enter the identifier for the domain you want to match (e.g.,
    • Click Add condition to add the next domain. (Add each domain you want to include in cross-domain measurement.)
    Conditions are evaluated using OR logic.
  6. Click Save.

Manual setup

The recommended approach is to configure cross-domain measurement via the Analytics interface. However, there might be scenarios where you need to implement a custom solution via the measurement code. In these cases, you can set it up manually by using the get and set commands of the gtag.js API to persist IDs across domains. Learn more about setting up cross-domain measurement manually.


To retrieve a client ID on the source domain, you use the get method:

  gtag('get', 'G-XXXXXXX', 'client_id', (client_id) => {
  // Store the client ID in a variable.
gtag('get', 'G-XXXXXXX', 'session_id', (session_id) => {
  // Store the session ID in a variable.


Once you have the client and session IDs, add them to the link that points to the destination domain:

<a href=""></a>


On the destination page, read the IDs from the URL and set them with the config command:

gtag('config','G-XXXXXXX', {
'client_id': getClientIdFromUrl(),
'session_id': getSessionIdFromUrl()

Verify that cross-domain measurement is working properly

  1. Open a page of your site that contains a link or a form that points to a domain you configured for cross-domain measurement.
  2. Click the link or submit the form to navigate to the destination domain.
  3. Verify that the URL in the destination domain contains the linker parameter _gl; for example:*abcde5*.


If you can't confirm the presence of the parameter _gl in the URL of the destination domain per the steps above, double check that the domain you configured in the interface matches the domain your site is pointing to.

It's also possible that your website is configured in a way that prevents cross-domain measurement from working correctly. With the help of an experienced web developer, investigate whether your website is being affected by the following issues.

URL redirects

If the destination page redirects or doesn't support arbitrary query parameters, the parameter _gl may end up being removed from the URL even if it was appended by Analytics in the previous page. (This usually happens too quickly to observe by eye.) To confirm if this is happening to your site, check the network requests made by the previous page using the Chrome Developer Tools. To fix this issue, configure your site to preserve the parameter _gl in redirects.

Conflicts with other scripts

Cross-domain measurement works by creating an event listener on the document node of a page. When users click a link, the click event bubbles up to the document node and the parameter _gl is added to the link URL. This process cannot work properly in the following scenarios:

  • When the navigation is triggered by JavaScript as opposed to a direct response to a user action.
  • When competing scripts in the page stop the event propagation before it reaches the document node; for example, when Event.stopPropagation() is used.
Was this helpful?
How can we improve it?
Clear search
Close search
Google apps
Main menu
Search Help Center