Solved

Merge API issues using Postman

  • 17 December 2020
  • 7 replies
  • 150 views

Hi there,

I have seen similar questions have been asked before, but none of them provided an answer to what I’m looking for.

So our situation is as follows:

  1. We just imported contacts from a CSV file and they were successfully added to Mixpanel.
  2. In that import, there were several duplicated of people using same name but different emails during their initial signup.
  3. As their emails are unique, I want to merge them together using the Merge API with Postman
  4. I set up a service account (owner role) for the project, and using Basic Auth in Postman with the credentials provided by Mixpanel
  5. I make a POST request as follows: https://api.mixpanel.com/import#identity-merge
  6. I set a raw text content as follows
    {
    "event": "$merge",
    "properties": {
    "$distinct_ids": [
    "first_id",
    "second_id"
    ],
    "token": "my_project_token"
    }
    }
  7. I send, get a 200 response and simply 0 as the body.
  8. I go back to Mixpanel, but the two users are not merged.

My question is:

Why doesn’t the above work?

icon

Best answer by mikeyherrman 15 January 2021, 00:29

Hi joergen,

 

It sounds like you could be running into some of the guardrails on the identify event.  It is possible to merge multiple email addresses together but you will probably need to use some of the other merging events (either alias or $merge).  You can see the different guardrails for the different ways of merging here.  To see what error is occuring, you can view you $identify events in Mixpanel and look for the failure reason and failure description properties on that event.

 

As to the emails being overwritten, the $email property in Mixpanel is a reserved property with some special functionality and you can only have 1 value there as you mentioned.  If you wanted to keep all three emails in a property (in addition to using them as distinct_ids for the user), you could create a list property to store each value or something like that.

 

Hope this helps!

View original

7 replies

Userlevel 6
Badge +3

@joergen —

As a first step for anyone starting to use ID Merge, you’ll need to first transition your Organization to our new Identity Management Scheme before you can use $merge, within your settings. 

The reason you are not seeing these profiles merge is because First and Last name with a different email does not signal that they are the same user.

Instead, I would use the deduplication method described here: 

 

ID Merge was designed to connect pre-login authenticated behavior back to a single profile.
For example, if a returning user cleared their cookies and triggered events on your website before logging in, our old Identity Management scheme could not connect the pre-login anonymous events back to the profile. 
 

ID merge system will 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 distinct_id value than the one used in the query. The id that is returned is the canonical id determined by Mixpanel for that user. 

It may take a couple of days for ID Merge to be enabled - You can read more about ID Merge here: https://help.mixpanel.com/hc/en-us/articles/360039133851

 

Thanks for your reply!

Our organisation have been having the Identity Merge enabled since we setup Mixpanel (less than a month ago). 

I’m not merging on first and last name, but on first_id and second_id as in first unique ID and second unique ID (first user and second user) hence:

{
"event": "$merge",
"properties": {
"$distinct_ids": [
"first_id",
"second_id"
],
"token": "my_project_token"
}
}

The use case is just that we have user a and user b whom is the same user, but signed up with different email. Now, if that user comes back, we want that user to recognised as the same user instead of two, say a new user known as user c (a+b=c). 

I don’t mind doing it manually for our users as we don’t have too many now, it’s more to understand how this can be easily done in Mixpanel. It is a bit strange to me that this option is not possible to do in the UI. Just have an option when selecting 2 or more users that is “Merge”. And they will be merged/consolidated into one.

Since that’s not possible, I would just like to understand how I can do it from Postman.

Also, a bit unrelated, but would it be possible for you to create a Postman Collection of your API? Would simplify API calls a lot.

Any update on this?

We also have another case now where a user signed up with the same email in the website as in the app, but mixpanel shows this as two different users, although their email is exactly the same in mixpanel.

Isn’t this the basic use case Identity Merge in mixpanel should handle?

Pinging this once again @cherise 

The use case is that we want to merge the identities across our Wordpress Website and our React Native app using Segment for both. If it’s possible to do it directly from the identify call, this would save us a lot of time.

Userlevel 6
Badge +3

@joergen —

Apologies for the delay, I was OOO over the holidays. 

I talked this over with my colleague @mikeyherrman and from your description, we would expect this to work. Our suggested next step/ guess to what is going on is that maybe you aren’t authenticating with your api secret? This is necessary when using /import.

Can you check on that for us?

I ended up using the email as the unique ID across the website and the react native app which seems to work for merging.

 

I have a follow up question:

What if the user has multiple emails? I.e. the user can be identified with emailA, emailB and emailC (it’s common a person has multiple email addresses). If I try to identify the same user with another email, it seems to override the previous email (that is now the user ID) and creates a new user in Mixpanel. If I set the email trait in properties to the new email, it also overrides the old email in traits, so I cannot have multiple emails for a user.

 

How can I add multiple emails to the same user as a unique identifiers?

Badge

Hi joergen,

 

It sounds like you could be running into some of the guardrails on the identify event.  It is possible to merge multiple email addresses together but you will probably need to use some of the other merging events (either alias or $merge).  You can see the different guardrails for the different ways of merging here.  To see what error is occuring, you can view you $identify events in Mixpanel and look for the failure reason and failure description properties on that event.

 

As to the emails being overwritten, the $email property in Mixpanel is a reserved property with some special functionality and you can only have 1 value there as you mentioned.  If you wanted to keep all three emails in a property (in addition to using them as distinct_ids for the user), you could create a list property to store each value or something like that.

 

Hope this helps!

Reply


Mixpanel