I have a question about distinct_id
Hi Danny M., 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
I wrote a code to call the identify function after the user logs in. When I tested it, distinct_id was replaced with user_id as I intended. However, when I look at the mixpanel event list of other users, distinct_id is assigned to device_id at the time identify is called, and user_id is assigned to a property called ‘Distinct ID Before Identity’. Why is there an item called ‘Distinct ID Before Identity’ property, and why is distinct_id not replaced with user_id?
The distinct_id
is a crucial identifier used by Mixpanel to uniquely track a user in the system. Every event data and profile update sent to Mixpanel should have a distinct_id
property associated with it. The distinct_id
value tells Mixpanel which user to attach your events and profile property updates to. It is used to provide a single, unified identifier for a user across devices and sessions. When two events have the same value of distinct_id
, they are considered as being performed by one unique user. If the distinct_id
on two events are two different values, they will be considered as coming from two separate users[^1^][^2^].In Mixpanel's Ingestion API, distinct_id
must be specified on every event, as it is crucial for Mixpanel to perform behavioral analysis (unique users, funnels, retention, cohorts) correctly and efficiently. If the event is not associated with any user, set distinct_id
to the empty string. Events with an empty distinct_id
will be excluded from all behavioral analysis[^1^].In Mixpanel's Group Analytics, you can establish an event property other than the distinct_id
, such as company ID, account ID, project ID, or billing ID, as an identifier by which to analyze your data[^3^].In Mixpanel's Identity API, properties.distinct_id
is an optional string that identifies the user post-identification[^4^].In debugging, you can manually trigger some events on your own device and search or filter using distinct_id
[^5^].[^1^]: Ingestion API - Events Methods > properties.distinct_id>
[^2^]: Identity Management Overview Distinct ID>
[^3^]: Group Analytics: Group users together as an aggregated unit of measurement Overview>
[^4^]: Create Identity
[^5^]: Debugging: Validate your data and troubleshoot your implementation Before You Debug > Find Yourself>
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Let me check the knowledge base for you again. One moment! 📚
The $distinct_id_before_identity
is an internal Mixpanel property used to track an event's original $distinct_id
before it was updated due to identity merging. This property is used in both the Original ID Merge and Simplified ID Merge systems[^1^]. Identity merging is a process in Mixpanel that helps to ensure data are attributed to your users accurately by maintaining ID mappings[^2^]. The $distinct_id_before_identity
property helps to keep track of the original distinct ID of a user before this merging process takes place.[^1^]: Reserved Properties: Properties used for system features Reserved Event Properties Part 3>
[^2^]: Identity Management Overview
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Let me check the knowledge base for you again. One moment! 📚
The distinct_id_before_identity
is an internal property used by Mixpanel to track the original distinct_id
of an event before it was updated due to identity merging. This property is not directly assigned by the user but is managed by Mixpanel's system[^1^].When a user interacts with an application, Mixpanel's SDK automatically generates a $device_id
and assigns it as the distinct_id
for the event. This distinct_id
is used to track the user's activities as an anonymous user[^2^][^3^].Once the user logs in or signs up, the identify()
function is called with the user's known identifier (e.g., their ID from your database), which sets the user_id
value. This user_id
is then used as the new distinct_id
for that user's events moving forward[^2^][^3^][^4^].When both $user_id
and $device_id
are present in the same event for the first time, Mixpanel creates a mapping to merge these two IDs together, forming an identity cluster[^2^]. This is when the distinct_id_before_identity
would reflect the original distinct_id
(which was the $device_id
) before the identify()
function was called.However, the distinct_id_before_identity
property is an internal property and its assignment is managed by Mixpanel's system. It's not something that users directly control or assign[^1^].[^1^]: Reserved Properties: Properties used for system features Reserved Event Properties Part 3>
[^2^]: Identifying Users (Simplified) Mechanism>
[^3^]: Identifying Users (Original) Client-side Identity Management>
[^4^]: Identifying Users (Simplified) Server-side Identity Management > Step 3 - Set the Authenticated ID once users log in>
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Let me check the knowledge base for you again. One moment! 📚
The identify(user_id)
function is used to assign the user_id
to the distinct_id
for a user's events moving forward. However, there are a few reasons why the user_id
might not be assigned to the distinct_id
:1. Implementation Issues: There might be an issue with how the identify
function is implemented. For example, if a static string is provided for all users instead of the new user ID, all users would actually send events with the same id value[^1^].2. Mixpanel's ID Selection: Mixpanel selects the distinct_id
using any of the IDs inside of an identity cluster. This means that even after identifying your user, Mixpanel may choose your user ID or one of the other IDs inside of the cluster (such as the device ID) to serve as the displayed ID for the user. This is random and not user-configurable[^2^].3. Delay in ID Merge Mapping: It may take up to 24 hours for the ID merge mapping to propagate to all other parts of the system. This means that, in some cases, when analyzing a funnel that spans pre-login and post-login behavior in real-time, some may be shown as dropped-off, even though they've performed the conversion event[^2^].If you've identified the problematic set of ID values, but you have not been able to identify the root cause in the implementation, you can reach out to Mixpanel's support team and provide the details you've uncovered so far[^1^].[^1^]: Hot Shard Limits Recovering from a hot shard > Changing your implementation > ID management issue>
[^2^]: Identifying Users (Original) FAQ Part 1>
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.