Solved

Multiple users on same device not working as I would expect

  • 9 November 2020
  • 3 replies
  • 15 views

Hi,

As the title suggest, I am struggling to get multiple users on the same device working. The situation is as follows:

  1. Users browse anonymous and gets a ‘random’ distinctId (98CB5B1C-7922-44C8-8FAC-ED03BD1BB564). 

     

  2. Users logs in. In code I call identify to set the distinctId (e.g. 114)

     

  3. User browses app on which each subsequent call distinctId of 114 correctly gets sent along

     

  4. User logs out, in code I call reset method to reset the distinctId and remove existing super properties. I see reset is being called due to logging in Xcode (I also call a flush just to be sure).
  5. Now the anonymous user does not get a new ‘random’ distinctId. Instead it gets the distinctId which was set in step 1.

 

The problem is that after calling identify, the ‘random’ distinctId of 98CB5B1C-7922-44C8-8FAC-ED03BD1BB564 is linked to 114. So this is linked to a logged in user. Also, in the documentation it states that it resets the distinctId which it sort of does, but not to a random new value, actually it sets it to an old value. The reason why I expect a new random UUID or something of that sort is this source under ‘Multiple Users on Single Devices: Identify on Login, Reset on Logout’ states: 

                “Mixpanel will treat subsequent events on the same device as performed by a new user. “

but this is not true in my case, because the ‘new user’ is the user previously logged in. This is also confirmed by going to the user’s profile where I can see the multiple linked distinctId’s to this user:


What am I missing?

 

Regards,

Bart

icon

Best answer by robin 9 November 2020, 16:42

There is an extra step in ios 

Mixpanel.mainInstance().reset()

let uuid = UUID().uuidString

Mixpanel.mainInstance().identify(distinctId: uuid)
View original

3 replies

Userlevel 3
Badge +3

There is an extra step in ios 

Mixpanel.mainInstance().reset()

let uuid = UUID().uuidString

Mixpanel.mainInstance().identify(distinctId: uuid)

Hi Robin,

 

Thank you for your answer. Where did you find that this needs to be done? Do you have an url?

 

Regards,

Bart

Userlevel 3
Badge +3

It was in a blog article and here too https://github.com/mixpanel/mixpanel-swift/issues/139

Reply