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 Edit: I started sending user_id, $user_id and $device id as well in events but problem was not solved. Screenshot of one tag 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. kapa.ai
It looks like the issue you're experiencing is related to how Mixpanel's Simplified ID Merge API handles prefixes and the mapping between $device_id and $user_id.Based on your description, here is why you are seeing two separate profiles and how to fix it:
Why this is happening
In Simplified ID Merge, Mixpanel treats any distinct_id that starts with $device: as an anonymous device. If you send an event with distinct_id as $device:phone_number, Mixpanel interprets the $device_id as phone_number. If you then send a profile update or an event with the distinct_id set to just the phone_number (without the prefix), Mixpanel interprets this as a $user_id. Because a mapping has not been established between the "device" and the "user," Mixpanel creates two separate profiles [Migrating to Simplified; Identity Management FAQ].
Recommended Solution
To merge these into a single profile, you must send at least one event that contains both the $device_id and the $user_id in the properties. This is the trigger that tells Mixpanel these two IDs belong to the same person [Understanding Simplified ID Merge].Follow these steps in your sGTM setup: 1. Uniform ID Strategy: Decide if the phone number is your $user_id. Mixpanel recommends using a single, unchanging database ID as the $user_id [Simplified ID Merge FAQ].
2. Trigger a Merge: In your "Track" tag, ensure you are sending both properties:
** $device_id: The identifier used by your CRM (e.g., the phone number).
** $user_id: Your unique internal ID for the user (if this is also the phone number, that is fine).
** When Mixpanel receives an event with both, it will merge them into one identity cluster. The $user_id will become the canonical distinct_id [Server-side Simplified].
3. Profile Properties: Set your profile properties (name, phone number) using the $user_id (the version without the $device: prefix). User profiles are set directly on the distinct_id, and in a merged state, the $user_id is the identifier you should target [Simplified ID Merge FAQ].
4. *Avoid Manual Prefixes: If you are manually adding the $device: prefix to the distinct_id field in sGTM, stop doing so. Instead, map the raw phone number to the $device_id property and let Mixpanel handle the internal mapping [Migrating to Simplified].
Summary of ID Mapping
** If only $device_id is present: distinct_id becomes $device:VALUE
** If $user_id is present: distinct_id becomes VALUE
** If *both are present: Mixpanel merges the two and uses the $user_id value as the distinct_id [Understanding Simplified ID Merge].If you continue to see two profiles, ensure that the value you are sending as $user_id in your track event exactly matches the $distinct_id you are using in your "Set" tag for profile properties [User Profiles 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.
Let me check the knowledge base for you again. One moment! đ
Yes, sending both $device_id and $user_id with every event without manually setting a distinct_id will solve the problem.In the Simplified ID Merge system, Mixpanel is designed to automatically manage the distinct_id for you based on these two properties: ** Automatic Merging: When Mixpanel receives an event containing both $device_id and $user_id, it automatically triggers a merge between the two. This connects the anonymous history (associated with the device) to the identified user profile [Understanding Simplified ID Merge].
** ID Priority: If both properties are present, Mixpanel will automatically set the distinct_id to the value of the $user_id. You do not need to provide the distinct_id property yourself because Mixpanel overrides or updates it whenever these reserved properties are detected [Understanding Simplified ID Merge; Server-side Identity Management].
** *Canonical Identity: For projects on Simplified ID Merge, the $user_id always becomes the "canonical" distinct_id used for queries and profile updates [Canonical Distinct ID].
Implementation Recommendation
For your sGTM setup, simply map your CRM's unique identifier (the phone number) to both $device_id and $user_id for the first identifying event, and at least to $user_id for all subsequent events and profile updates. This ensures that:
1. The event is attributed to the user profile (via $user_id).
2. Any previous events that only had the $device_id (the anonymous version) are retroactively merged into the same profile [Example User Flows].By not sending a manual distinct_id yourself, you avoid the risk of accidentally applying the $device: prefix incorrectly, which was causing your events and profile properties to split into two different records [Migrating to Simplified ID Merge].
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.
what about identify tag? should I just stop it and only send track and set tag?
Let me check the knowledge base for you again. One moment! đ
Based on the knowledge sources, whether you should continue using an explicit "Identify" tag depends on which ID Merge API your project is using.
If you are using Simplified ID Merge
You do not strictly need a separate Identify tag if you are already sending $device_id and $user_id with your events. ** Mechanism: In Simplified ID Merge, identity merging is triggered automatically when a $user_id and $device_id are detected in the same event for the first time [Simplified ID Merge Mechanism].
** Recommendation: You can simply use your Track tag to send both $device_id and $user_id. This single instance is adequate to trigger the merge [Understanding Simplified ID Merge]. You should then use the Set tag (profile update) using the $user_id to ensure properties are attached to the correct identified profile [Simplified ID Merge FAQ].
If you are using Original ID Merge
In this version, an explicit identity event is required to bridge the two IDs.** Mechanism: Original ID Merge determines distinct IDs using the $identify event. You must call a method that sends this event to merge an anonymous ID and a chosen user ID under one identity cluster [PHP identity Management].
** Recommendation: If your project is on the Original API, you must keep the Identify tag to link the IDs [Server-side Best Practices].
Summary of Action
Since you mentioned your problem involves the $device: prefix (which is a hallmark of the Simplified ID Merge logic), you are likely on the Simplified API [Migrating to Simplified ID Merge]. In that case, you can stop using the separate Identify tag as long as your Track tag includes both $device_id and $user_id. This simplifies your implementation and ensures the server-side logic handles the distinct_id assignment automatically [Server-side Simplified].Important Note: Before removing the tag, verify your API version in Project Settings > Identity Merge to confirm you are on Simplified ID Merge [Check Project Settings].
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.
kapa.ai I stopped identify I am sending $user_id and $device_id with every event. The events are coming from crm that's why I have information I stopped sending distinct id so that mixpanel handle it itself I have another tag of set I am sending same $user_id and $device_id The problem of having device keyword in distinct id is resolved now but I still see two profiles for each user now One have events Another have properties but no events
Let me check the knowledge base for you again. One moment! đ
The reason you are still seeing two profiles is likely because of how User Profiles are handled compared to Events in Mixpanel's Simplified ID Merge system.According to the knowledge sources, here is why this is happening and how to fix it:
The Cause: Identity vs. Profile Updates
In Mixpanel, User Profiles are set directly on a specific distinct_id. While events can trigger an identity merge by containing both $device_id and $user_id, profile updates (your "Set" tag) behave differently: 1. Events: When you send a track event with both $device_id and $user_id, Mixpanel automatically sets the distinct_id as the $user_id and merges the two IDs in the background [Understanding Simplified ID Merge].
2. Profiles: User profile updates (the "Set" tag) are sent to the Engage API. This API requires a $distinct_id property. If your sGTM "Set" tag is sending properties without an explicit $distinct_id (or if it's using an identifier that Mixpanel hasn't finished merging yet), it may create a new profile [Identity Management Overview].
Why the profiles are split
** Profile 1 (Events): Created because your "Track" tag successfully uses $user_id as the identifier.
** Profile 2 (Properties, No Events): Created because your "Set" tag is likely sending a profile update that Mixpanel is not yet associating with the same identity cluster. User profile properties are not preserved when $device_ids are linked to $user_ids; any properties set before the IDs are fully linked must be set again using the $user_id [Simplified ID Merge FAQ].
The Solution
To ensure properties and events land on the same profile, you should: 1. Explicitly set $distinct_id in your "Set" tag: Unlike events, profile updates strictly use the $distinct_id field in the payload. Ensure your sGTM "Set" tag maps your unique identifier (phone number/user ID) specifically to the $distinct_id field [Identity Management Overview].
2. Wait for the Merge: It can take up to 24 hours for an identity merge (connecting $device_id to $user_id) to propagate to all parts of the system, including the join between the Events table and the User Profiles table [Simplified ID Merge FAQ; User Profiles FAQ].
3. Use the $user_id value for Profiles: Ensure the "Set" tag uses the exact same string value for $distinct_id as the value you are sending in the $user_id field of your "Track" tag. Do not include the $device: prefix here [Simplified ID Merge FAQ].Summary: For your "Set" tag, make sure you are mapping your identifier to the field named $distinct_id (note the dollar sign for profiles) and that the value matches your $user_id exactly [Identity Management Overview].
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.
