Mixpanel Community Icon

Resolving Duplicate User IDs in Mixpanel for B2B Subscriptions

·
·

I have a question about user identification. We are using mixpanel on frontend. We have a b2b application for accountants. They can have one subscription with multiple users. But we do not care how many users they have. We are trying to track only subscriptions. So that we are setting UserId from by using mixpanel API. When I want to identify how many unique subscribers using a functionality I can get a list from Users menu by filtering Users with profile and related event. After downloading event when I check the UserId column still there exist dublicates. Why? How can I resolve it?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Your question is about user identification in Mixpanel for a B2B application tracking subscriptions. Let me address your concerns based on the information available.The issue you're experiencing with duplicate UserIds in your downloaded event data, despite setting a UserId using the Mixpanel API, could be related to how Mixpanel manages user identity. Here are a few key points to consider:1. Distinct ID vs User ID: Mixpanel uses a "distinct_id" to uniquely identify users in the system. This may not always be the same as your UserId. As mentioned in the Identity Management Overview, "The Distinct ID value tells Mixpanel which user to attach your events and profile property updates."2. ID Merging: Mixpanel has different systems for ID management. If you're using the Original ID Merge system, you need to explicitly merge identities using the identify() method. According to the PHP SDK documentation, you can merge an anonymous ID and your chosen user ID like this:

    ```LBKSLBKS3. Server-side Identity Management: If you're managing IDs on the server-side, you need to ensure you're setting the `distinct_id` correctly for each event. As stated in the [Server-side Identity Management](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-original#server-side-identity-management) documentation, "If you're tracking from servers, you'll need to generate and manage the IDs yourself and set it as the `distinct_id` directly."LBKS4. Canonical Distinct ID: Even after identifying users, Mixpanel may choose a different ID to display. As explained in the [FAQ](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-original#faq), "The canonical distinct_id is selected by Mixpanel using any of the IDs inside of a cluster. This means that even after identifying your user, Mixpanel may choose your user ID or one of the other IDs inside of the cluster (such as the device ID) to serve as the displayed ID for the user. This is random and not user-configurable."LBKSTo resolve this issue:LBKS1. Ensure you're correctly implementing the `identify()` method to merge anonymous and authenticated user IDs. 2. Set your chosen user ID (in your case, the subscription ID) as a separate user profile property and event property. This way, you can always query and see your own chosen user ID. 3. When querying or exporting data, use your custom user ID property instead of relying solely on Mixpanel's `distinct_id`.LBKSIf these steps don't resolve your issue, you may need to review your implementation or contact Mixpanel support for more specific guidance tailored to your setup.

    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.