Hey I am receiving events from CRM into sGTM. We have to use phone number as a unique identifer of the user. I am using Stape's templates for Mixpanel. Setup I have three tags. - For Identify - For Set (to set name and phone number) - For Track I have phone number with every event of CRM. I am sending phone number as distinct_id. Looks like sending distinct_id is mandatory Problem The problem is two users are being created. First User: Profile properties set up with name and phone number I set and No events in the profile Second User: No profile properties are set up but there are events logged for that profile There's a difference in distinct id as well in both users First user has distinct id exact phone numer but second user has distinct id starting from $device:phone number What could be the solution to this problem? Has anyone implemented mixpanel using sGTM.
Hi Anas, 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
This issue occurs because of how Mixpanel’s Simplified ID Merge (or the server-side logic it uses) handles identifiers.When you send a phone number as a distinct_id without specific prefixes or accompanying properties, Mixpanel interprets it differently depending on whether you are sending a profile update or an event.
The Cause: Identity Mismatch
The reason you see two separate profiles is that Mixpanel treats a plain ID and an ID prefixed with $device: as two different entities until they are formally merged.** First User (Profile only): When you send a profile set update (Identify/Set tags) with the phone number as the distinct_id, Mixpanel creates a profile for that exact string [Identity Management Overview].
** Second User (Events only): When sending events, if the system (or sGTM template) detects that the ID is not yet "identified" or is being treated as an anonymous identifier, it may automatically prefix it with $device:. In the Simplified ID Merge logic, any distinct_id with a $device: prefix is treated as a $device_id, while a value without it is treated as a $user_id [Migrating to Simplified ID Merge].
The Solution
To fix this and ensure both events and properties land on the same profile, you should follow the recommended server-side identity pattern: 1. Use $user_id instead of just distinct_id:
In your sGTM Track tag, ensure you are mapping the phone number to the $user_id property. If you provide a $user_id, Mixpanel will use that value as the canonical distinct_id for the event [Identifying Users (Simplified)].2. Align Profile Updates:
Ensure your Identify and Set tags use the exact same phone number string (without any $device: prefix) as the $distinct_id for profile updates. Mixpanel joins events and profiles at query time based on the distinct_id matching the profile's $distinct_id [User Profile FAQ].3. Explicit Mapping (Recommended for sGTM/Server-side):
If you are using the Simplified ID Merge API, the most robust way to handle this is to send both properties in your events:
** $device_id: Set this to the phone number (or a session ID).
** $user_id: Set this to the phone number.
When Mixpanel receives an event with both for the first time, it creates an identity cluster linking them [Server-side Identity Management].
Important Note on Phone Numbers
Mixpanel generally recommends using a non-changing internal database ID as a $user_id rather than a phone number or email. If a user changes their phone number in your CRM, they will be treated as a completely new user in Mixpanel because $user_id values cannot be merged or changed in the Simplified API [Identifying Users (Simplified) FAQ].
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.
