Mixpanel uses two types of IDs to handle user identification — Distinct ID and User ID.
A Distinct ID is a random ID assigned to the anonymous user. All user activity before the user registers or logs in to your product is processed by Mixpanel against the Distinct ID.
As an example, when user A lands on the website, Mixpanel will set a Distinct ID for this user, let’s call the ID ‘X’.
When the user triggers some events, Mixpanel associates all events from this user to the Distinct ID ‘X’. So, now Mixpanel knows which events were performed by user A with Distinct ID ‘X’.
User A then goes ahead and creates an account on your website using their email address. At this point, Mixpanel identifies the user with the email address they entered — let’s call it ‘E’ — which now becomes the User ID in Mixpanel for that user.
Mixpanel takes care of mapping the Distinct ID and User ID, i.e, Distinct ID ‘X’ is associated with User ID ‘E’.
Now let’s assume that this same user A pays another visit from a mobile device. At this point, Mixpanel doesn’t know who the user is and assigns a new Distinct ID ‘Y’.
The user then logs in using their email address ‘E’ and that’s when Mixpanel identifies the user.
The difference here is that this time Mixpanel already knows the user with email ‘E’ and will therefore merge the activities of Distinct IDs ‘X’ and ‘Y’. This results in user A’s activities being merged across website and mobile.
It’s good to keep in mind that the same process works even if you don’t use email at the time of signing up and use another identifier such as backend ID. The only thing that is important is that the identifier has to be unique for a given user.