Mixpanel Super Properties are stored in the cookie, so every time a new one is registered, cookies can grow. And if you are registering a large number of Super Properties or very large values (e.g., lists of activities), the cookie can exceed the size that browsers can handle; bloated cookies can potentially degrade app and site performance.
Carefully consider Super Properties
While super properties can be extremely useful, it behooves you to choose what you send to the client cookie carefully; cookie size isn’t an issue in mobile apps, but unfortunately, cookie size limits are a fundamental limitation of client-side tracking for web.
If your cookies are becoming too bloated:
Consider re-evaluating what you’re storing as Super Properties, especially if you’re also storing them as People Properties - are they providing value as Super Properties? If not, whittle down to the essentials.
Consider re-evaluating the format of your Super Properties - for example, if you are sending a list of every page the user has viewed, you might send only the last 10 pages the user viewed instead.
Switch from cookies to localStorage
If you’ve re-evaluated your Super Properties and their formats and still have not been able to sufficiently shrink the cookie or have decided you are getting value out of the Super Properties you’re sending, you could also explore the option of leveraging localStorage.
To do this, set the Mixpanel config to persistence:localStorage instead of the defaultpersistence:cookie ; read additional details in our developer documentation.
Things to keep in mind when switching from cookies to localStorage
- For older browsers that don't support localStorage, the browser will fall back to cookies as your data is copied over on switching the config.
- Using localStorage inherently does not allow access across subdomains the way that HTTP cookies do. If this concerns or is relevant to you, consider manually setting a cookie that is is shared across subdomains for each user's distinct_id; for example, mixpanel_distinct_id:
- Before any identification, check for the mixpanel_distinct_id cookie.
- If the cookie is set, grab the cookie, parse the distinct_id out, and pass it in as a parameter to an mixpanel.identify() method.
- If the cookie isn't set, you may generate a new distinct_id using the mixpanel.identify() method.
If changing Mixpanel cookies to localStorage is still resulting in cookie-related issues, consider looking into cookies from any other third-party integrations you may have on your site.