where does mixpanel web sdk store the device id info in the browser ?
Hi Zeyad Y., 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
The Mixpanel Web SDK stores the device ID (the $device_id property) in the browser using either localStorage or cookies, depending on your configuration. By default, the SDK uses cookies for persistence, but you can configure it to use localStorage by setting the persistence option to "localStorage" when initializing the library: LBKSmixpanel.init('YOUR_PROJECT_TOKEN', { persistence: 'localStorage' });LBKS
If you require cross-subdomain tracking, you should use the default cookie persistence, as localStorage does not support cross-subdomain access. Disabling persistence entirely (with disable_persistence: true) will prevent the device ID from being stored, which also disables anonymous-to-identified user tracking and super properties Quickstart FAQ.In summary, the device ID is stored in either a cookie or localStorage, based on your SDK configuration.
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.
and what is usually the expiration value for that cookie ?
Let me check the knowledge base for you again. One moment! 📚
By default, the Mixpanel cookie—which stores the device ID and other super properties—has an expiration value of 365 days. You can change the cookie's lifetime by setting the cookie_expiration configuration option during initialization. For example, to set the cookie to expire in 90 days: LBKSmixpanel.init('YOUR_PROJECT_TOKEN', { 'cookie_expiration': 90 });LBKS
This will adjust how long the device ID and other super properties persist in the browser cookie Setting Super Properties.
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.