Cross-domain tracking

Track one visitor across your main site and subdomains.

Last updated June 3, 2026

Use this when your marketing site, app, docs, or checkout live on subdomains of the same domain. A visitor who lands on example.com and then opens app.example.com should stay one visitor in Grometrics, not become two separate people.

Nothing extra to configure

Install the normal tracking snippet on each related host with the same data-site value. Grometrics handles the shared visitor cookie automatically.

Steps

1

Use the same snippet everywhere

Paste the same Grometrics script on your main site, app subdomain, docs, and any checkout pages you control.

Replace YOUR_SITE_ID with your site ID from Settings > Tracking.

HTML

1<script defer src="https://usegrometrics.com/g.js" data-site="YOUR_SITE_ID"></script>
2

Keep the visitor together

When someone moves between subdomains, the tracker reuses the same anonymous visitor id where the browser allows it.

3

Still see where events happened

Each event keeps its real hostname, so you can still filter traffic from the main site, app, docs, or checkout.

Common Setups

PathVisitorReports
example.com to app.example.comSame anonymous visitorEvents show the real hostname
docs.example.com to app.example.comSame anonymous visitorDocs and app traffic stay filterable
example.com to an external checkoutSeparate browser domainUse checkout metadata or a return URL to reconnect revenue

What happens next

To check it, open Realtime, visit the main site, move to a subdomain, and confirm one visitor timeline includes both hostnames.

Troubleshooting

It still looks like two visitors

Confirm both hosts use the same data-site value and that the browser is not blocking first-party cookies.

A third-party checkout breaks the path

Use the supported checkout integration or return URL so payment attribution can reconnect the sale to the original visitor.

Was this page helpful?