Skip to content

Subdomains and multiple domains

Subdomains report into the same site automatically; other domains need adding, and cookies need a shared parent.

One Statsy site can measure more than one host. What works depends on whether those hosts share a parent domain.

Subdomains are included already

Beacons are accepted from your site’s domain and from any subdomain of it. A site on yourstartup.com also accepts app.yourstartup.com, docs.yourstartup.com and blog.yourstartup.com with no extra setting. Every host appears in your reports, so you can filter or compare them.

Other domains have to be added

A different domain, a staging host such as yoursite.webflow.io, or a preview deployment is rejected until you list it under Site settings › General › Additional domains. Up to 20 additional domains can send data to the same site, and each of them also covers its own subdomains.

What data-domain actually controls

data-domain does not decide which hosts are accepted. It decides which links count as leaving your site: a click on a link to any other host is recorded as the outbound goal. Set it to your main domain and links between your own subdomains stop showing up as outbound traffic.

One visitor across hosts

In full mode the visitor id lives in a first-party cookie, which the browser scopes to the host that set it. To share one visitor across hosts, list them on the tag and the cookie is set on their common parent domain:

html
<script defer
  data-website-id="ws_XXXXXXXX"
  data-domain="yourstartup.com"
  data-cross-domain="www.yourstartup.com,app.yourstartup.com"
  src="https://statsy.co/js/script.js"></script>

The script takes the longest suffix the listed hosts have in common, here yourstartup.com, and sets the cookie there. Hosts with no shared parent, such as yourstartup.com and yourstartup.io, cannot share a cookie: a browser will not let one domain write a cookie for another.

Hosted checkouts are handled for you

The one cross-domain hop that matters is checkout. When a visitor in full mode clicks a link to a hosted Stripe, Lemon Squeezy, Paddle, Polar or Razorpay checkout, the script appends the visitor id to that link as the provider’s own custom field, and records the checkout_start goal. The payment webhook then carries the id back, which is how the sale is credited to the visit that produced it.

Note. Measuring two products that share nothing but an owner is usually clearer as two Statsy sites. Additional domains are for one product served from several hosts.

Last updated · Markdown version