Call mixpanel.identify(knownId) once you know who the user is - it tells Mixpanel that future events from this browser belong to that known ID. Call mixpanel.alias(newUserId) only once, at the moment of first signup, to permanently merge the anonymous pre-signup activity into the new profile; never call alias() again for the same user. Update profile fields with mixpanel.people.set() after identify(), not before - "people.identify()" is not a method in modern SDKs.
Why this happens
Mixpanel tracks anonymous visitors under a randomly generated distinct_id stored in a cookie or local storage. When a visitor becomes a known user, there are two distinct jobs: telling Mixpanel that future events belong to the known ID (identify), and telling Mixpanel that a specific anonymous ID and a new known ID are the same historical person, merging their pre-signup activity (alias, one time only, at signup).
Confusing these two calls is the single most common Mixpanel identity bug: calling alias() on every login instead of only at signup creates broken merge chains, and calling identify() with an ID that does not match anything creates orphaned profiles that never connect to the pre-signup funnel.
Fix it
- On first signup: call
mixpanel.alias(newUserId)immediately, before any other identify/track call for that user, then callmixpanel.identify(newUserId)right after. - On every subsequent login (not signup): call
mixpanel.identify(existingUserId)only - never call alias() again for that user. - On logout: call
mixpanel.reset()so the next visitor does not inherit the previous identity. - Update profile properties with
mixpanel.people.set({...})after identify() has run, never before - a people.set() call issued before identify() attaches to the wrong, pre-merge profile. - If an older SDK version in your stack still exposes a "people.identify()"-style call, check that SDK's current docs - that method name was deprecated in modern JS/web SDKs in favor of identify() driving both event and profile association.
How to verify it worked
In Mixpanel, open the merged user's profile and check the "first seen" date - it should reflect the original anonymous session, not the signup date, confirming the merge worked. Use Live View during a manual test signup and watch the anonymous distinct_id's events reassign to the new profile in real time. If two separate profiles persist for what should be one person, alias() either fired more than once or fired after identify() instead of before.