Check 41.12 · Tracking and analytics setup

Set up cross-domain tracking if needed

Check whether your user journey spans several domains, set up cross-domain tracking in GA4 or Matomo, list unwanted referrals and test _gl.

Priority
Critical
Difficulty
Intermediate
Estimated time
30 min to 2 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

When a visitor moves from one of your domains to another, for example from the brochure site example.com to the booking engine example-reservation.com, the analytics tool treats them as two people, and the second visit seems to come from your own site. Cross-domain measurement passes the visitor's identifier from one domain to the other in the URL. Once it is set up, a booking or a purchase is attributed to the real original source: organic search, AI assistant or campaign.

Why it matters

GA4 and Matomo identify a visitor with a first-party cookie tied to a domain. A cookie set on example.com cannot be read from example-reservation.com. Without configuration:

  • the same visitor counts as two users and two sessions;
  • the session on the second domain has example.com as its source (a “self-referral”);
  • conversions on the second domain are attributed to your own site instead of Google, ChatGPT or the newsletter.

This is often where the value of SEO disappears: the organic page brings in the visitor, but the sale is credited to the brochure site as a “referral”.

Cross-domain measurement only applies to domains you control and on which you can install the same tag. For an external provider (PayPal, a bank, Stripe), you do not set up cross-domain tracking: you list its domain as an unwanted referral.

What it improves

  • Conversion attribution Sales and bookings on the second domain go back to the real source.
  • User and session counts No more artificial duplicates.
  • SEO and GEO measurement Visits from search engines and AI assistants keep their credit all the way to the conversion. See document the limits of attribution (opens in a new tab).
  • Rankings No effect.

How to check

  1. List the domains in the journey: site, shop, booking, customer area, payment. For each, note whether it belongs to you and carries your tag.
  2. Look for self-referrals: in GA4, Reports > Acquisition > Traffic acquisition, dimension “Session source / medium”. If example.com / referral appears while you are in the example.com property, or if your two domains cite each other, measurement is broken.
  3. Look for providers: paypal.com / referral or a bank's domain as a source of transactions points to unwanted referrals.
  4. Test the hand-off: click a link from domain A to domain B. If the GA4 configuration is active, the landing URL contains ?_gl=1*…; for Matomo, it contains pk_vid=….

How to implement

Before you start: do you need it?

Situation Cross-domain? Action
A single domain and its subdomains (www, boutique, blog) with the same GA4 tag Usually not GA4 sets its cookie on the root domain by default; just check that there are no self-referrals
Brochure site and shop or booking on another domain you own Yes Configure both domains in the same stream
Several country domains (example.fr, example.de) with a shared checkout Yes, if the journey goes from one to the other Same stream, or separate streams if the sites are independent
Payment with a provider (PayPal, Stripe Checkout, 3-D Secure) No Unwanted referrals
Third-party tool embedded in an iframe (calendar, booking) Not applicable See the iframes section
A vendor's booking engine that accepts your GA4 tag Yes Ask the vendor to install the same G-… tag

Essential condition: every page of every domain involved carries the same Google tag, with the same G-… ID from the same data stream.

With GA4

You need the Editor role on the Google Analytics account.

  1. Admin > Data collection and modification > Data streams, click “Web”, then your stream.
  2. At the bottom of the page, click “Configure tag settings”.
  3. In the “Settings” section, click “Configure your domains”.
  4. Domains that already use the same tag appear under “Recommendations”: click “Add” to accept them.
  5. Otherwise, under “Include domains that match ANY of the following conditions”, click “Add condition”, choose a match type and enter the domain: example.com, then example-reservation.com. Conditions are combined with OR.
  6. Click “Save”.

The tag then adds the _gl parameter to links and forms that lead from one configured domain to another. Clicks to these domains are no longer counted as outbound clicks by enhanced measurement.

If you install the tag through Google Tag Manager, or through an extension such as Site Kit on WordPress or the Google & YouTube channel on Shopify, the setting is made in the same place, in the GA4 interface: nothing to change in the container, as long as the Google tag uses the same ID on both domains.

List unwanted referrals

For providers that send the visitor back to your site without carrying your tag:

  1. Same path up to “Configure tag settings”, then “Show more”.
  2. Click “List unwanted referrals”.
  3. Under “Include referrals that match ANY of the following conditions”, add one condition per domain: paypal.com, the domain of your bank's authentication page, the domain of the hosted payment provider.
  4. Save.

Visits coming back from them receive the ignore_referrer parameter and keep their original source. A stream accepts up to 50 conditions. The setting does not correct past data.

Warning: do not add to unwanted referrals a site that sends you real visitors, such as a directory or a partner, nor the domains of AI assistants: you would lose exactly the information you are trying to measure.

With Matomo

  1. Administration > Websites > Manage, edit the site and list all your domains in the Alias URLs field (at least two).
  2. Administration > Websites > Tracking Code, open the advanced options and enable cross-domain tracking.
  3. Check that the tracking code contains:
_paq.push(['setDomains', ['*.example.com', '*.example-reservation.com']]);
_paq.push(['enableCrossDomainLinking']);
  1. Install this same code, with the same site ID, on every listed domain.
  2. Test: a link from one domain to the other must add the pk_vid parameter to the landing URL.

With Matomo Tag Manager: Tag Manager > Variables, edit the “Matomo Configuration” variable, tick the cross-domain linking option and list the domains. Links added with JavaScript after the page loads do not receive pk_vid automatically: use the getCrossDomainLinkingUrlParameter method to add it.

The hand-off only works if the parameter survives the trip:

  • Redirects: if the destination domain redirects (http to https, adding www, language), the redirect must keep the query string. On Nginx, return 301 https://www.example-reservation.com$request_uri; keeps _gl; a rule that rewrites to a fixed URL removes it.
  • Navigation triggered in JavaScript (window.location = … after a click): GA4 only decorates real clicks and form submissions. Use a real <a href> link or a form.
  • Scripts that stop propagation (event.stopPropagation()): the tag listens to clicks at the document level and does not see these clicks.
  • Rejected parameters: some booking engines return an error on an unknown parameter. Test the full journey, downloads included.

Google also documents a manual method, which reads client_id and session_id with the gtag.js get command and passes them in the URL. Keep it for cases where the interface is not enough.

Iframes

A tool embedded in an iframe (appointment booking, reservations, hosted form) runs on the vendor's domain. Link-based cross-domain measurement does not apply, and browsers increasingly restrict third-party cookies. Three options:

  • replace the iframe with a link to a page of the tool that carries your tag, with cross-domain measurement;
  • use the events the vendor sends to the parent page through postMessage, if it documents them, to send the conversion event yourself;
  • failing that, measure the conversion on the vendor's side (confirmation email, export) and reconcile it manually.

Check after setup

  1. With Tag Assistant, follow the journey from domain A to domain B: the client ID (client_id, visible in the collection requests) must be the same on both sides.
  2. Two to three days later, the share of example.com / referral should drop in Traffic acquisition.
  3. Conversions on the second domain appear under their original sources (google / organic, chatgpt.com / referral…).

Common mistakes

  • Two different tags (one stream per domain): cross-domain measurement requires the same G-… ID everywhere.
  • Setting up PayPal or the bank as cross-domain instead of unwanted referrals: their site does not carry your tag, so the setting is useless.
  • A redirect that drops _gl, often between example-reservation.com and www.example-reservation.com.
  • Links built in JavaScript or buttons that change window.location: the parameter is never added.
  • Excluding a real partner as a referral: its traffic disappears from the reports.
  • Forgetting the consent banner on the second domain: without consent on domain B, the visitor is not measured there, whatever the configuration. See handle applicable consent requirements (opens in a new tab).
  • Expecting past data to be corrected: the setting only applies going forward.

Frequently asked questions

Do you need to set up cross-domain tracking for subdomains in GA4?

Usually not. With the same GA4 tag on every subdomain, the cookie is set on the root domain and shared by www, shop or blog. Google still recommends checking that there are no self-referrals: if a subdomain uses a different cookie domain, add the domains to the cross-domain configuration and check that every page carries the tag.

What is the difference between cross-domain tracking and unwanted referrals?

Cross-domain measurement links two domains that you control and that carry the same tag: the visitor keeps the same identifier from one domain to the other. Unwanted referrals concern third-party domains, such as PayPal or a bank, that send the visitor back to your site: GA4 no longer counts them as a source, and the visit keeps its real origin.

Why does the _gl parameter not appear in the URL?

First check that the destination domain is listed exactly in the GA4 configuration. Then look for a redirect that removes the query string, navigation triggered by JavaScript rather than a real link, or a script that stops click propagation. The browser's developer tools, Network tab, show whether _gl was present before the redirect.

Does cross-domain tracking work with a booking tool in an iframe?

Not with GA4's link-based method: the iframe runs on the vendor's domain, and browsers restrict third-party cookies. Replace the iframe with a link to a page of the tool that carries your tag, or use the events the vendor sends to your page, if it documents any. Failing that, reconcile confirmed bookings with your audience data.

Updated on

Topic checklist (PDF)

And now?

In the “Tracking and analytics setup” topic

  1. Set up Google Search Console
  2. Verify the domain property via DNS
  3. Set up Bing Webmaster Tools
  4. Set up GA4, Matomo or an equivalent
  5. Set up Google Tag Manager if needed
  6. Check data collection
  7. Handle applicable consent requirements
  8. Track conversions, forms and quote requests
  9. Track phone and email clicks
  10. Track downloads and sign-ups
  11. Track purchases
  12. Set up cross-domain tracking if needed
  13. Fix duplicate conversions
  14. Exclude internal traffic if relevant
  15. Identify organic and AI landing pages
  16. Create a dedicated channel for AI traffic
  17. Identify ChatGPT, Perplexity, Gemini, Copilot and Claude referrers
  18. Use available UTM parameters
  19. Connect analytics to the CRM if relevant
  20. Measure lead quality and revenue
  21. Document the limits of attribution
  22. Set up Consent Mode v2 if you use Google tags