Skip to main content

The script

Subdomains and multiple domains

Which hostnames a site accepts events from, and how to add more.

Subdomains work with no configuration

A site registered as example.com accepts events from:

  • example.com

  • www.example.com

  • blog.example.com

  • docs.example.com

  • anything.deeper.example.com

Paste the same tag, with the same data-domain="example.com", on all of them. They all report into one dashboard.

www. is ignored entirely, so www.example.com and example.com are the same host in both directions.

Telling them apart on the dashboard

The Pages card has a Hostname tab. It ranks your subdomains the way the Page tab ranks paths, so you can see how much of your traffic is the docs and how much is the marketing site.

The Page tab itself is keyed by path, so /pricing on your marketing site and /pricing in your docs share a row. Switch to Hostname when that matters, or filter to one hostname and read the paths underneath it.

A different domain entirely

example.org is not a subdomain of example.com, so it needs listing.

In the site's settings, add it under Allowed hostnames. Or on the tag:

<script
  defer
  data-website-id="ts_a1b2c3d4e5f6"
  data-domain="example.com"
  data-allowed-hostnames="example.org,example.net"
  src="https://truestat.io/js/t.js"
></script>

Comma-separated, hostnames only. Each entry also covers its own subdomains, on the same rule as data-domain.

What happens if you forget to list one

The event is still recorded. Nothing is lost.

What changes is that the collector does not return the header that makes its response readable to the browser, so your console shows a CORS error. That is a diagnostic telling you to add the hostname; it is not data loss.

We chose it that way round on purpose: a customer who adds a subdomain and forgets to list it should see their traffic, not a silent hole in it.

Internal links between your own hostnames

By default, a click from example.com to blog.example.com records the blog view with example.com as its referrer — so it lands in your Referrers breakdown as if it were an outside site sending you traffic.

To make internal navigation count as Direct instead, list your own hostnames under Self hosts in the site's settings. Every hostname you list there is treated as "not an external referrer".

This affects how visits are sorted into channels — see Channels.

Visitor identity across subdomains

On the default first-party cookie mode, a visitor moving from example.com to blog.example.com is recognised as the same visitor, because the cookie is set on the registrable domain.

On the two cookieless modes, identity is derived from the request and the hostname is not part of it, so cross-subdomain recognition also works — for as long as the identifier lasts, which is a day on rotating hash and an hour on strict. See Identity and cookieless mode.

Both subdomains must be on the same mode. Recognition compares like with like: a cookie identity and a derived identity never match, so a visitor moving between a subdomain on the cookie mode and one on a cookieless mode is counted twice. If you set the mode per site rather than leaving the default, check that every subdomain reporting into it agrees.

Page views are unaffected either way — each is counted once and lands on the right hostname. What breaks is the link between two visits, which matters when you read a funnel across subdomains: the drop-off between them will look like people leaving when they did not.

Truly cross-domain tracking

Following one person from example.com to example.org and knowing it is the same person is supported on the default cookie mode, between domains you list yourself. When someone clicks a link to one of your listed domains, the script attaches their visitor id to that link, and the receiving page adopts it instead of minting a new one. The parameter expires after 60 seconds, so a decorated link pasted into a chat does not carry one person's identity to everyone who clicks it.

It only reaches domains you listed. A link to a site you do not own is left untouched — following people across sites you do not own is the thing this product is built not to do.

It does not work on the two cookieless modes. There, identity is derived from the request and never stored in the browser, so there is nothing to carry across. Those domains still report into one dashboard; the same visitor on both counts twice.

The full setup is in Tracking one visitor across two domains.

Was this page helpful?

Last updated September 17, 2026