Mixpanel and herokuapp.com subdomains (and other common top level domains)

Note: If you’re looking for information on how to track users throughout your site’s domains (like mymarketingsite.com to mysite.com) or if your users' distinct_ids are changing across different pages (or subdomains) of your site, read instructions on how to track users across domains. The information presented in this article below only applies to those with hosted domains, like mysite.herokuapp.com.


By default, Mixpanel cookies span subdomains. However, if your site is hosted on a domain like Heroku (or similar - see a complete list of affected domains) with a URL like XYZ.herokuapp.com, cross-subdomain cookies are not allowed for security reasons. With Mixpanel default settings on these sites, users' distinct_ids will be reset to a new $distinct_id on each page load. This will cause issues with Mixpanel reports, namely broken Retention reports and Funnels.

Step back: What is distinct_id?

To resolve the issue on sites that don't allow cross-subdomain cookies:

Change the cross_subdomain_cookie config setting in your mixpanel.init function to false, which will allow your subdomain's cookie to be stored and keep the Mixpanel distinct_id consistent across the sub-domain:

mixpanel.init(PROJECT_TOKEN,{cross_subdomain_cookie:false});

Or, use a CNAME to change from yourdomain.herokuapp.com to yourdomain.com.