All articles

Tutorials

Several domains, one site: aliases and cross-domain stitching

Track one product across example.com, app.example.com and a checkout domain: aliases accept the hits, and optional stitching keeps one visit together.

3 min readUpdated
Several domains, one site: aliases and cross-domain stitching cover image

Key takeaways

  • Aliases let one site accept hits from several hostnames.
  • Cross-domain stitching keeps a visit together across them, and is off by default.
  • Stitching stores an identifier in the browser, so check your consent setup first.

Aliases: accept hits from more hostnames

A PureStats site has one canonical domain and only accepts hits from domains it knows. That protects your reports from strangers sending events with your domain. When the same product runs on app.example.com or checkout.example.com, add those hostnames as aliases. The www or non-www variant of your domain is added automatically.

Use aliases for parts of one product: marketing site, app, checkout, help center. For unrelated sites, such as two clients of an agency, create separate sites instead; All sites can still show them together.

Why a visit splits without stitching

Without cookies, PureStats recognises a visitor by a daily hash of the shortened IP address and the browser. Within one hostname that works well. Across hostnames it usually works too, because the hash does not depend on the domain, but a visit can still split, for example when the checkout runs on another provider's domain or the address changes during the handoff.

When the split matters for your reports, typically for attributing a purchase on a checkout domain to the campaign that brought the visitor, stitching closes the gap.

How cross-domain stitching works

Stitching is a per-site setting, off by default. When it is on, the tracker keeps a random visitor and session ID in a first-party cookie called psid, with a copy in localStorage. With the linker option, links between your allowed domains carry the ID in a short-lived _ps parameter, which the tracker on the other domain reads and then removes from the address. A handoff is valid for two minutes.

The visit then stays one session from the first page to the last, and the conversion on the checkout domain belongs to the source that started the visit.

  1. Add every hostname of the product as an alias.
  2. Enable cross-domain session stitching in the site's privacy settings.
  3. Keep Use linker parameter for handoffs on if the domains do not share cookies.
  4. Click through from one domain to the other and check that the visit stays one session.

The privacy trade-off

Stitching is the one common feature that stores an identifier in the visitor's browser. That is exactly what the default mode avoids, and in many places it means you need consent before you set it. If your site already asks for analytics consent, combine stitching with the manual opt-in consent mode; if it does not, ask whether a split visit really costs you more than a consent banner.

Frequently asked questions

Do I need stitching for subdomains?

Usually not. Add the subdomains as aliases; enable stitching only if visits still split in a way that matters.

What does stitching store?

A first-party cookie named psid with a random visitor and session ID, and a copy in localStorage.

Should I track two client sites as one site?

No. Create one site per product and use All sites to see them together.

Add your domains

Create a site, add your aliases and check the first hit from each hostname on the setup page.

Start free