Set up cross-domain measurement in GA4
When your site and your app or shop are on different domains, set up GA4 cross-domain measurement so one visit isn't counted as two. Subdomains need nothing.
If your marketing site and your app or shop are on different domains (for example mysite.com and mysiteapp.com), set up cross-domain measurement in your GA4 data stream, so a visitor moving between them stays one visit with its original source. Subdomains of the same domain (mysite.com and app.mysite.com) work without it.
Do you need it?
| Your setup | Need cross-domain? |
|---|---|
mysite.com and app.mysite.com | No: subdomains share GA4's cookie automatically |
mysite.com and mysite.io | Yes |
mysite.com and a checkout on Stripe, PayPal or Paddle | No: use unwanted referrals instead |
Set it up
Put the same GA4 tag (same Measurement ID) on both domains.
In GA4, open Admin → Data streams → your web stream → Configure tag settings → Configure your domains.
Add a condition for each domain, for example Contains mysite.com and Contains mysite.io. Save.
GA4 then adds a short _gl= parameter to links between the domains, which carries the visitor across.
Check it works
Click a link from one domain to the other: the address should include _gl=. In GA4's Realtime report, the visit keeps its original source instead of showing your other domain as a referral.
Sources
- Google: Set up cross-domain measurement
Last updated
Data retention
GA4's data retention setting keeps detailed data for 2 or 14 months. What it affects (explorations), what it doesn't (standard reports), and why to choose 14.
Next.js
Add GA4 to a Next.js App Router site with the official @next/third-parties package or next/script, keep the ID in an environment variable, and track signups.