Skip to content
English
  • There are no suggestions because the search field is empty.

How to enable cross-domain tracking in Google Analytics 4 (GA4)?

This manual explains how to enable cross-domain tracking in Google Analytics 4 (GA4) using query parameters in the URL.
👉What data can be collected from GA4?

Cross-domain tracking allows you to track users as they move across different domains while maintaining a single Analytics session and avoiding duplicated data.

How do you activate cross-domain tracking?

Add the domains parameter to the URL
To enable cross-domain tracking, add the domains parameter to the URL, including the list of domains separated by commas.

💬 For example:

https://ejemplo.com/path?domains=dominio1.com,dominio2.com,subdominio.dominio3.com


💬 Practical example

Original URL:

https://160-f1401014.spalopia.app/es/engine/163/channel/web/utb-spa-booking-simple?rfh_currency=EUR&clear_filters=1

URL with cross-domain tracking enabled:

https://160-f1401014.spalopia.app/es/engine/163/channel/web/utb-spa-booking-simple?rfh_currency=EUR&clear_filters=1&domains=spalopia.com,booking.spalopia.app

Correct domain format
The domains included in the domains parameter must meet the following conditions:

  • Separated by commas and without spaces (domain1.com,domain2.com)
  • No protocol included (http:// or https://)
  • Subdomains can be included (sub.example.com)

💬 For example:

  • ?domains=example.com
  • ?domains=example.com,booking.example.com
  • ?domains=spalopia.com,booking.spalopia.app,www.spalopia.com

System behaviour

  • Configuration priority
    The system applies the cross-domain tracking configuration following this priority order:
    1. domains query parameter (highest priority)
    2. google-ga4-domains session value
    3. Persistent configuration
    • Session persistence
      When the domains parameter is received via URL:
      • It is automatically stored in the session.
      • It is reused on subsequent pages for the duration of the session.
      • It can be overwritten by sending a new value via the query parameter.

    💬 For example:

    <iframe src="https://dominio-externo.com/path?domains=dominio-principal.com,dominio-externo.com"></iframe>


    Verifying that it works:

    • From the browser
      1. Open the developer tools (F12).
      2. Go to the Network tab.
      3. Filter by gtag or collect.
      4. Check that the request contains the _gl parameter
        (this indicates that the GA4 linker is active).
    • From the JavaScript console

      Verify that events have been generated with the domain configuration by running:

      console.log(window.dataLayer);

    💡 Important notes

    • The domains parameter must be present on both involved domains.
    • Domains must be correctly written (no spaces, no protocol).
    • All domains must use the same GA4 tracking code.
    • The value stored in the session is reused automatically.
    • You can override the configuration by adding a new value via the query parameter.

     

     

    📩 If you have any questions during the process, please write to soporte@spalopia.com