How can I match my user id to the mixpanel user or device id for reporting?
Hi Stephen S., 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
To match your user ID to the Mixpanel user or device ID for reporting, you need to properly implement user identification in Mixpanel. Here's how you can do it:
1. For anonymous users, Mixpanel automatically generates a $device_id. This serves as the anonymous ID for the user.
2. When a user logs in or signs up, you should call the .identify() method with your chosen user ID. This links the anonymous $device_id to your user ID.
3. For server-side tracking, you need to manage the IDs yourself. Set the $device_id for anonymous events and both $device_id and $user_id for identified users.
Here's an example of how to implement this in PHP:
```
LBKSThis approach ensures that your user ID is properly linked to Mixpanel's internal IDs for accurate reporting.
As a best practice, you should also set your chosen user ID as a separate user profile property and event property. This allows you to always query and see your own chosen user ID in reports.
For more detailed information, you can refer to these resources:
- [Identifying Users (Simplified)](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-simplified#server-side-identity-management)
- [Mixpanel SDKs: PHP](https://docs.mixpanel.com/docs/tracking-methods/sdks/php#managing-user-identity)
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.
