Hi, we just enabled Session Replay for our application. We doesn't care about build in distinctId as our flow can we spread across multiple devices and all our metrics care about our internalId which is added to every event. It is possible to make that works similar for session replay as for metrics?
Hi Sewo B., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
Mixpanel’s Session Replay feature fundamentally relies on the concept of a distinct_id to associate replays and events with users. The distinct_id is the unique identifier used by Mixpanel to track users across events and devices. While you can add your own internalId as a property to every event for your own metrics and analysis, Session Replay itself requires a distinct_id to function and link replays to user sessions.However, you can influence which value is used as the distinct_id. If you want your internalId to be the primary identifier for both metrics and session replay, you can set it as the distinct_id when initializing the Mixpanel SDK or when calling identify. This way, both your metrics and session replays will be associated with your internalId, even if users move across devices—provided you consistently use the same internalId for the same user across all devices and platforms.Here’s how you can set the distinct_id to your internalId: Web Example:iOS Example::**LBKS```LBKSMixpanel.mainInstance().identify(distinctId:: "<your_internal_id> ") MPSessionReplay.getInstance()?.identify(distinctId: "<your_internal_id> ")**Android Example:**mixpanel.identify("<your_internal_id> ") MPSessionReplay.getInstance()?.identify(distinctId: "<your_internal_id> ")```Important Considerations:** - The distinct_id is the only identifier used by Mixpanel to link events and session replays. If you do not set it to your internalId, session replays will not be associated with your internalId, and cross-device tracking will not work as you expect. - If you use your internalId as the distinct_id everywhere, you will get consistent user tracking across devices for both metrics and session replay. - If you only add internalId as a property and do not set it as the distinct_id, session replays will not be grouped by your internalId.Summary: To make session replay work the same way as your metrics (i.e., based on your internalId), you must set your internalId as the distinct_id in the Mixpanel SDK on all platforms and devices. There is no built-in way to have session replay use a different identifier than distinct_id, nor to have it automatically use a custom property for grouping replays.For more details, see the documentation on identity management and Session Replay configuration.
If you have events coming from multiple sources (e.g., server-side), ensure you use the same distinct_id (your internalId) everywhere for proper server-side stitching of replays and events Replay ID (Web).
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.
Does it many any difference when mixpanel.identify('<your_internal_id>'); is fired? Does it need to be executed before any event send?
Let me check the knowledge base for you again. One moment! 📚
Yes, the timing of when you call mixpanel.identify('<your_internal_id> ') does matter.Best Practice:
You should call identify() as soon as you know the user's identity (typically at login or registration), and before sending any events that you want to be associated with that user. This ensures that all subsequent events are attributed to the correct user (i.e., your internalId) and that Mixpanel can properly merge pre-login (anonymous) and post-login (identified) activity for a unified user profile.If you send events before calling identify(), those events will be associated with the anonymous $device_id rather than your internalId. Only events sent after identify() will be linked to the internalId. For proper identity stitching and accurate analytics, always call identify() before sending events for an identified user Identifying Users (Simplified) – Client-side Identity Management.Summary:
- Call identify() as soon as the user is authenticated.
- Call it before sending any events you want linked to the user's internalId.
- This ensures all events are correctly attributed and identity merging works as expected.If you need to merge pre-login and post-login events, make sure to send at least one event after calling identify() to trigger the merge Identifying Users (Simplified) – Client-side Identity Management.
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.
