Mixpanel cookie

  • 1 December 2020
  • 3 replies

Tracking cookie is becoming a problem. Can Mixpanel be used  in a website without using cookie? 

3 replies

Yes, there’s a configuration option `disable_persistence` which will prevent the SDK from setting a cookie or localStorage. The effect will be that superproperties don’t get persisted between pageloads; everything else should work.

If the issue is only with the cookie’s size, you might consider using localStorage instead:

mixpanel.init(`<YOUR TOKEN>`, {persistence: `localStorage`});


@tdumitrescu Thanks! 

our flow is the following

  1. user login
  2. mixpanel.user.identify(userId, userAttrs)
  3. mixpanel.event.track(eventName, eventAttrs)

we are a single page app. but users could reload their pages.

if we disable cookie, can event.track still identify the user? if not, is there a solution to tie events to the user between pageload?


If there’s no client-side persistence (i.e. you’re using neither cookie nor localStorage) then your app needs to set any superproperties it wants explicitly on each pageload. Assuming your frontend has access to userId, you can call mixpanel.identify() with the userId as part of your page’s initialization process.

Similarly, if you’re trying to track anonymous (pre-signup/login) activity accurately across pageloads without using any sort of browser persistence, then it’s up to your app to implement this explicitly. One way to do it might be to keep a GUID on the URL as a query param ( and read that out in your JS to use as a distinct id. It’s a pain and not very robust, but when you’re trying to persist data across pageloads without using the browser’s built-in persistence mechanisms your options are pretty limited.