Question
How does Analytics.js track users across subdomains?
Product
Segment
Environment
Segment Console
Answer
Analytics.js tracks users across subdomains by default. To enable this, include the Analytics.js snippet on each subdomain you want to track. Segment sets the anonymousId on the top-level domain, allowing the same anonymousId to be accessed by all subdomains and ensuring consistent user tracking.
You can use either the same Segment source for all subdomains or separate sources, depending on your tracking goals.
Additional Information
Tracking across different top-level domains is not supported out of the box. To track users across top-level domains, use Segment’s Querystring API to pass the anonymousId in the URL. Analytics.js will read and set the anonymousId from the query string when a user moves between domains.