Solved

ID Merge not happening on log in

  • 27 February 2021
  • 5 replies
  • 59 views

I need help with connecting an existing user to the log in event I’m tracking. ID Merge is enabled for the project.

When I log in with a user, I always get two log in events in the Live View:

The sequence of Mixpanel calls in the code is

  1. track log in event (when user clicks on “Log in”)
  2. identify user with user id after authentication

According to the ID Merge notes this is the suggested sequence, and connecting the user after identification to the pre-auth event does occur as shown above. However, the second event at the bottom of the screenshot is a duplicate event.

How to prevent that?

icon

Best answer by Muffaddal Qutbuddin 1 March 2021, 07:43

Ok yeah so in your case it does make sense to trigger login event before identify as it is not related to when user performances login action, actually login one time.

Anyways, your code looks good, are you sure the profile with distinct ids 84e. and 177e…, from the image, are of same user?  because if you are passing the same user id on identification Mixpanel will merge the profiles.

Have you tried viewing both of the profiles in Mixpanel? there are cases when MP shows two profiles in user view and live view but once opened it shows one single profile. 

View original

5 replies

Userlevel 3
Badge +2

Hello @jost-s , can you share the code you are using to identify the user?
also I will suggest to first identify the user and then sent the event, this ensure that event is sent to identified user profile only.

@Muffadal sure, the code is

 

mixpanel.track(‘People - log in’);

...

if (user.authorized) {

  mixpanel.identify(userId);

}

 

I understand that identifying the user first would solve the issue, but I do not know the user ID when the user presses the “Login” button. As far as I understand ID Merge, the tracked events prior to identification are assigned retrospectively to a user after identification. This works by the way very well when I’m using `mixpanel.identify()` after signing up.

The problem with doing it the other way around

 

if (user.authorized) {

  mixpanel.identify(userId);

  mixpanel.track(‘People - log in’);

}

 

is, that the log in tracking is triggered every time the user reloads the page or starts the browser and opens the page.

Userlevel 3
Badge +2

Ok yeah so in your case it does make sense to trigger login event before identify as it is not related to when user performances login action, actually login one time.

Anyways, your code looks good, are you sure the profile with distinct ids 84e. and 177e…, from the image, are of same user?  because if you are passing the same user id on identification Mixpanel will merge the profiles.

Have you tried viewing both of the profiles in Mixpanel? there are cases when MP shows two profiles in user view and live view but once opened it shows one single profile. 

Right, I’ve checked and it looks like it’s assigned to the right user and only “wrongly” displayed in the list.

In any case it’s currently working as expected. I’d let you know if it happens again. Thanks for your immediate help, Muffaddal!

Userlevel 3
Badge +2

Right, I’ve checked and it looks like it’s assigned to the right user and only “wrongly” displayed in the list.

In any case it’s currently working as expected. I’d let you know if it happens again. Thanks for your immediate help, Muffaddal!

I am very glad to help.

Reply


Mixpanel