Cross-Domain Tracking for GA4
Build the GA4 cross-domain config for gtag.js or GTM. Supports multiple destination domains, custom query parameters, and anchor-fragment linking. Also verifies if an existing URL already has the
_gl linker parameter.
Measurement Intelligence
Without cross-domain tracking, GA4 treats example.com and checkout.example.com as two separate sessions.
The GA4 linker passes a
_gl parameter between domains carrying the user's client ID, so GA4 stitches the session together. Without it, your checkout appears as "direct" traffic even though it came from a Google-paid campaign on your main site.
Config
Include every domain where you track the same user journey. Subdomains are usually auto-linked, but list them explicitly to be safe.
Generated code
gtag.js config
Place after your main gtag config call
Verify an existing URL
Troubleshooting
- Check both domains have the same Measurement ID. Linker only works between tags that share the same GA4 property.
- Links need to be clicked, not scripted. The linker intercepts click events on anchor tags. If your "link" is a JavaScript redirect, you need to call
gtag('get', ...)and append_glmanually. - Check that
_glappears on the destination URL. Click a link from source and destination, inspect the URL in the address bar. If no_glparameter, the linker isn't firing. - Match domain spelling exactly.
www.example.comandexample.comare different for the linker unless you list both. - Verify in GA4 DebugView. Both source and destination page_view events should share the same client_id.
Frequently asked questions
What is cross-domain tracking?
The ability to track one user across multiple domains (yoursite.com and payment.processor.com and yoursite.com) as a single session in GA4.
How does it work?
The source domain adds a
_gl parameter to outbound links. The destination domain reads it and continues the GA4 session with the same client ID.When do I need cross-domain tracking?
Checkout flows on external payment processors, lead forms on vendor-hosted booking tools, multi-brand portfolios, any sub-domain that uses a different GA4 property.
How is it set up?
In GA4: Admin and Data Streams and Configure tag settings and Configure your domains. List all domains to link.
Do I need the same GA4 Measurement ID on all domains?
Yes. The ID must match for session continuation.
What does the generator produce?
The gtag.js configuration (or GTM linker variable config) plus a tester for the _gl parameter.
Does cross-domain tracking work with Consent Mode v2?
Yes. Both work together. Consent Mode gates the whole GA4 behaviour; linker handles the cross-domain mechanism.
What about sub-domains of the same domain?
By default, GA4 treats sub-domains as the same site (cookie_domain=auto). No linker needed for sub-domains.
How to test cross-domain?
Click a link from the source domain; the destination URL should contain
?_gl=1*.... GA4 Realtime should show the session as continued, not new.Does cross-domain tracking survive 301 redirects?
Depends on how the redirect handles query strings. Preserving the _gl parameter through redirects is critical.
What is iframe cross-domain tracking?
Different problem. Iframes with GA4 need separate configuration (postMessage to parent). Not covered by the linker.
Free · no account
SEORCE for Chrome, Edge and Firefox
Audits the page you are on: headings, meta tags, schema, indexability, and whether AI crawlers can read it. Export the result as a PDF. Free, with no account.
It audits one page at a time and does not track AI answers. About the extension
Traffic from search and AI
See which visits came from search and AI.
SEORCE Web Analytics runs from one script tag, with Google Search Console connected. It shows visits from every AI source, from search and from campaigns, and it is free on every plan.
3,000+ users · Free forever plan, no card needed