Solved

How to merge different user ids/records into one distinct id?

  • 20 March 2020
  • 2 replies
  • 1236 views

Badge +1

I have few user records that suppose to be on the same “distinct id”.  This is due to our incorrect implementation at first by not setting the USER_ID property when calling mixpanel.people.set().  

After fixing this issue, I now would like to merge those records into one “distinct id”.   I look in the Organization Setting  that we can request for Identity Merge.  Is this the only way to do it?  Can someone suggest the way to merge those records into one?  Is there anything to be aware of before doing so?

icon

Best answer by Cassandra 20 March 2020, 20:14

View original

2 replies

Userlevel 1
Badge +1

Hi @noom,

Enabling ID merge and importing a $merge event to map events from merged ids together is likely the best solution. One nuance to note:

  • User profiles will not automatically aggregate all user properties when merged: If multiple user profile exists for multiple distinct ids that are merged, Mixpanel will hide all but one of the user profiles. User property values will not be updated or added based on other profiles merged. 

Alternatively, you could delete profiles that are duplicated without enabling ID merge,  however the events from different profiles would not be merged together. For this reason, enabling ID merge is likely the best solution.

 

warmly,
Cassandra

Hey @Cassandra ! Thank you so much for helping @noom out here, this helped me solve my problem (I accidentally overwrote all our users unique IDs with new UUIDs in our db, so I needed to reconcile them in Mixpanel!)

Question though: I was under the assumption that the duplicate user profile would be “hidden” from my Users list, although I’m not seeing this in effect. I need my quantity of users with a “set email” to be accurate, and unfortunately this is clouding my numbers. 

Any advice? Maybe it takes an extended period of time? I’ve waited about 24 hours for my early test $merge users and they’re still showing two profiles...(but when I click either one it links to the same user profile, telling me that one of them is no longer in action?)

---

For those that are curious how I did this: I exported my user list as .csv from Mixpanel’s UI, wrote a simple custom script to loop through all users in the CSV (I recommend node-csv) and identify+collect duplicate emails and the two $distinct_ids Mixpanel had for them (one with the original UUID, and another for the new UUID caused by my original mistake :sweat_smile: ) and then called the $merge POST request using node-fetch on each pair. This request accepts an array with two $distinct_ids to merge. If you’re wondering how to put this request together, it wasn’t immediately obvious, but in Mixpanel’s API docs (using the link above), you have to add “body params” (at the bottom) and your project secret (which seems to get encoded after entering it in the form below) and then copy the example from the interactive API request builder on the right into your code. 

You can see the script that I used to accomplish this here: https://gist.github.com/waycroft/1c867deea54ef3b6112d6947c22eefa0 (not the prettiest, but it works!)

Reply