How do I properly ensure I am properly implementing cross domain tracking?
Hi Dave M., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> ๐
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
To properly implement cross-domain tracking in Mixpanel, you should consider the following key points:
1. Use cookie persistence: By default, Mixpanel uses cookies for cross-subdomain tracking. Ensure you're not using localStorage persistence, as this doesn't support cross-domain tracking.
2. Keep cross_subdomain_cookie enabled: The default setting allows Mixpanel cookies to work across subdomains. Only disable this if you're dealing with hosted subdomains that don't allow cross-subdomain cookies.
3. Use HTTPS: To ensure secure transmission of cookie data, it's recommended to use HTTPS for your requests.
Here's how you can configure these settings:
```
// create an instance of the Mixpanel object mixpanel.init('YOUR_PROJECT_TOKEN', { 'cross_subdomain_cookie': true, // Enable cross-subdomain tracking (default) 'secure_cookie': true // Prevent transmitting cookie with non-HTTPS requests });
LBKSIt's important to note that if you're using hosted subdomains (like [yourdomain.hostapp.com](http://yourdomain.hostapp.com)) that don't allow cross-subdomain cookies, you might need to disable cross-subdomain cookies or use a CNAME to change from [yourdomain.hostapp.com](http://yourdomain.hostapp.com) to [yourdomain.com](http://yourdomain.com).
For more detailed information on Mixpanel cookie configuration, you can refer to the [Mixpanel Cookie documentation](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#mixpanel-cookie).
Remember to test your implementation thoroughly in a development environment before pushing to production. This will help ensure that your cross-domain tracking is working as expected.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
โน๏ธย Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
