Track visitors across domains

Keep one visitor when people move between your site and a checkout or app on a different domain.

Updated

Cookies belong to one domain. If your marketing site is example.com and your checkout runs on example-checkout.com, each domain would see a different visitor. Cross-domain tracking hands the visitor over when someone follows a link between them.

First: do you need it?#

Subdomains do not need it. The same snippet on example.com, www.example.com and app.example.com already shares one visitor, because the tracker sets its cookies on the registrable domain. See Subdomains and extra domains.

You also do not need it for Stripe Payment Links: the tracker adds the visitor id to buy.stripe.com links on its own, so the payment is matched to the visit (how revenue is matched).

Set it up#

  1. In your project, open Settings and expand Advanced.
  2. Under Extra domains, enter the other domain (for example checkout.example.com or example-checkout.com) and click Add. It must be a different registered domain, not a subdomain: "Only for a checkout or app on a different domain (not a subdomain)."
  3. Paste the same tracking snippet, with the same website id, on the other domain.

Once both domains are on the project, links from one to the other carry a short hand-off in the URL hash (_bst=), and the tracker on the other side picks up the same visitor. Clicks to those domains are no longer counted as outbound links.

If you build the URL in JavaScript (for example a redirect after a form), add the hand-off yourself:

const url = window.boostra?.("decorate", "https://example-checkout.com/pay") ?? "https://example-checkout.com/pay";
window.location.href = url;

You can also list the hosts on the snippet with data-cross-domain, as a comma-separated list, when you manage the tag yourself.

Check it#

Open your site, click through to the other domain, and run window.boostra("ids") in the console on both sides: the visitorId should be the same. The journey then shows up as one visitor in Live Events.

Related articles