In Mixpanel, Users can have multiple Distinct IDs that can be merged under 1 identity. The User is identified with a default Distinct ID, which we’ve noticed is the first one created, not the most recent or one that we would explicitly prefer as the default.

Is it possible to set a default/primary Distinct ID?

Also related, once a user signs up, we are using email address as the Distinct ID. If the user changes their email address, would we need to create an alias (we have Identity Merge enabled, FYI), or update the Distinct ID with their new email?

enter image description here

I did read on this support article titled "Moving to Identity Merge" that:

You can no longer control the canonical id for users in Mixpanel The ID merge system will now determine which distinct_id is used as the canonical id for a user in Mixpanel. Any merged id can be used to query for information about a user with our APIs, but the results of the query may return a with different canonical distinct_id value than the one used in the query.

1 Answer

I had a similar issue, we use a server-side implementation but this should apply to client side as well, my flow was:

  1. send some anonymous track() events with anon_id & distinct_id uuidv4. Let's say the anon_id is: abc-123
  2. authenticate user (now we have access to user_id)
  3. call identify() with user_id and anon_id
  4. send some track() events with our internal user_id as the distinct_id. For example the user_id is: 1001

We noticed that the default mixpanel canonical distinct_id would always be abc-123, not 1001 like we wanted.

After playing around with the mixpanel API I have discovered that if you create the user profile before identifying, the problem seems to be fixed.

mixpanel.people.set(distinct_id, props); mixpanel.identify(); // our api is identify(user_id, anon_id) 

Going through he flow again, the canonical distinct_id is now 1001 instead of abc-123. I believe this fixes it because creating a profile for the user sets the canonical distinct_id (no source on this though).

To be clear, the flow afterwards is:

  1. send some anonymous track() events with anon_id & distinct_id uuidv4: abc-123
  2. authenticate user
  3. call mixpanel.people.set(distinct_id, props) // distinct_id = user_id
  4. call identify() with user_id and anon_id
  5. send some track() events with our internal user_id: 1001

Then 1001 should be the default canonical distinct_id instead of abc-123.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.