what is the alias() function in Mixpanel
Hi event, 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
The alias()
function in Mixpanel is used to link two non-anonymous Distinct IDs, effectively creating an alias for a user. This allows Mixpanel to interpret a new identifier (the alias) as an existing user, so events sent with either ID are attributed to the same user in Mixpanel. The function is typically used when a user transitions from an anonymous state (e.g., browsing before login) to an identified state (e.g., after signing up or logging in).- In the Original ID Merge and Legacy ID Management systems, calling .alias()
triggers a $create_alias
event, which merges the alias with the original distinct ID. This is useful for ensuring that pre- and post-signup activity is attributed to the same user. The alias can only point to one distinct ID, and multiple aliases can point to the same distinct ID, but not vice versa.- In the Simplified ID Merge system, the alias()
function and $create_alias
event have no effect and should not be used. Identity merging in this system is handled by including $device_id
and $user_id
properties on events, not by aliasing IDs.Example payload for $create_alias event::**LBKS```LBKS{
"event":: "$create_alias",
"properties": {
"distinct_id": "original_distinct_id",
"alias": "new_alias_id",
"token": "YOUR_PROJECT_TOKEN"
}
}```Important:** The alias functionality is only relevant for projects using the Original or Legacy ID Merge systems. It does not work in projects using the Simplified ID Merge system Create Alias API Reference Identity Management Overview.For more details, see the Mixpanel documentation on 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.
Let me check the knowledge base for you again. One moment! 📚
To confirm if your Mixpanel project is using the Simplified ID Merge system, navigate to your project’s settings: 1. Go to your Mixpanel dashboard. 2. Navigate to Project Settings. 3. Look for the Identity Merge section.Here, you will see which ID management version is enabled for your project. If it states "Simplified ID Merge" or "Simplified API," then your project is using the Simplified ID system. You cannot change the ID management version if your project already contains data Identity Management Overview Identifying Users (Simplified).For organization-wide defaults, you can also check the Identity Merge setting under your Organization Settings if you have the appropriate permissions 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.
Let me check the knowledge base for you again. One moment! 📚
For server-side tracking in a Mixpanel project using the Simplified ID Merge system, you need to manage user identity by including the reserved properties $device_id
(for anonymous users) and $user_id
(for identified users) in your event payloads. Here’s how you do it: 1. Generate and persist an anonymous ID (e.g., a UUID) for each user session and store it (commonly in a cookie).
2. Track anonymous events by setting the $device_id
property to this anonymous ID. You do not need to set distinct_id
; Mixpanel will use $device_id
as the distinct_id
if $user_id
is not present.
3. When the user logs in or is identified, set both $device_id
(the same anonymous ID) and $user_id
(the authenticated user ID) in your event properties. This will trigger Mixpanel to merge the anonymous and identified states.
4. After identification, you can continue sending both properties, or just $user_id
for subsequent events.**Example pseudocode (Python-like):**LBKSproperties = { "$device_id": session_id # your generated anonymous ID } if user_is_authenticated: properties["$user_id"] = user_id # your authenticated user IDLBKSmp.track("", event_name, properties)LBKS
- Do not send $identify
, $create_alias
, or $merge
events—these are ignored in Simplified ID Merge.
- The distinct_id
will be set automatically by Mixpanel based on the presence of $user_id
or $device_id
 Server-side Identity Management Sending Live Data.This approach ensures that user activity is properly merged and attributed across anonymous and identified states in your server-side tracking.
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.