So when users are identified the identity function is called to map the same user activity, if we want to do the same for unsuccessful login activities but still map same user activity, there is a data point consistent that is being passed for both identified successful login and unidentified unsuccessful login. Suggestions on how to execute this kapa.ai
To track both successful and unsuccessful login attempts and map them to the same user (even if the login is unsuccessful and the user remains anonymous), you should leverage the consistent anonymous identifier—typically the $device_id
—across both event types.How to execute this:Key Points:
- The $device_id
acts as the consistent data point across both unsuccessful and successful login attempts.
- After a successful login and identity merge, all events tracked with the same $device_id
(including failed logins) will be attributed to the identified user in Mixpanel.
- Do not call .identify()
on unsuccessful logins—only on successful ones. For unsuccessful attempts, just track the event with the $device_id
.Example (Pseudocode):Summary:
Use $device_id
as the consistent identifier for both unsuccessful and successful login events. Only call .identify()
on successful login, and always include $device_id
in your events to ensure proper mapping and merging of user activity streams in Mixpanel.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
This approach suggested is not working because at the point of entry, the user is not known so their past activities when signed in is not mapped to their activities when not signed in, so we are passing 1 value to the downstream app and it can be used to uniquely identify a user even in a user not logged in state kapa.ai
Let me check the knowledge base for you again. One moment! 📚
Thank you for clarifying your scenario. Based on the Mixpanel documentation, the recommended approach for mapping pre-login (anonymous) and post-login (identified) activities relies on the use of a consistent anonymous identifier—specifically, the $device_id
. This ID is generated and persisted by the Mixpanel SDK (or by your server, if tracking server-side) and is used to associate all events from the same device/session before the user is identified.Key points from the documentation:If you are finding that past activities are not being mapped after login, possible reasons include:
- The $device_id
is not truly persistent across sessions or is being regenerated, breaking the link between anonymous and identified events.
- The .identify()
call is not being made correctly, or the event that includes both $device_id
and $user_id
is not being sent after login.To ensure correct mapping:
- Make sure the same $device_id
value is used for all events from the same user/device/session, both before and after login.
- On successful login, call .identify(<user_id> )
and send an event with both $device_id
and $user_id
.
- Do not call .identify()
or set $user_id
for unsuccessful logins; just continue tracking with $device_id
.**Example from the documentation:**LBKS// Anonymous event { "event": "View Page", "properties": { "token": "{{token}}", "$device_id": "persistent-anonymous-id" } }LBKS// After successful login { "event": "Sign In", "properties": { "token": "{{token}}", "$device_id": "persistent-anonymous-id", "$user_id": "user123" } }LBKS
This will merge the anonymous and identified activity streams for the user Understanding Simplified ID Merge.If you are already following this approach and still not seeing the expected mapping, please double-check that the $device_id
is truly persistent and not being reset or changed between anonymous and identified states.If you have a custom identifier that is unique and persistent for each user (even before login), you can use it as the $device_id
to achieve the mapping you described.If you need more specific troubleshooting, please provide details on how $device_id
is being generated and persisted in your implementation.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.