Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Override distinct_id in Mixpanel After Calling identify #169

Open
sharifelshalabi opened this issue Oct 22, 2024 · 1 comment
Open

Comments

@sharifelshalabi
Copy link

I am encountering an issue with setting a custom distinct_id for Mixpanel events. Currently, Mixpanel defaults to using the device ID as the distinct_id. I am attempting to override this by explicitly calling identify with a custom user ID. My code is structured as follows:

instance
   .identify(user.id?.toString() ?? '')
   .then((_) => user.analyticParams.forEach(instance.getPeople().set));

The expected behavior is that Mixpanel should use the user.id provided in the identify method as the distinct_id for all subsequent events. However, it seems that Mixpanel still defaults to the device ID instead of the custom ID I've set.

Image

@FernandoReynaga
Copy link

Hey @sharifelshalabi 👋
I've contacted support team for this exact same reason and this was their answer:

When you call identify() using a specific parameter, we decide in a non-deterministic way what the canonical (main) distinct_id will be.

Please see the note from our docs here:
The distinct_id is programatically selected by Mixpanel, using one of the IDs inside of an identity cluster, based on the most optimal merging process. This means that the canonical distinct_id could be set to a $device_id or your chosen user_id. This is not user-configurable. You can use any of the IDs in the cluster for ingestion, but only the canonical distinct_id can be used in queries and exports.

Basically, an identify() call from an anonymous user will merge user1 (anonymous) and user2 (identified). Mixpanel calculates the "better" canonical distinct ID that is computationally efficient and is not user-configurable. It could end up being any of the IDs from the identity cluster, which is essentially all the identifiable IDs for that particular user — your user_Id or the initial anonymous ID/Device ID.

If you want to find a user by a specific value, I recommend setting a separate user property in addition to a distinct_id. This will guarantee you will be able to find users by this identifier.

I've also seen this happen when I start testing with multiple devices, causing the identity cluster to start having multiple records and that's when MixPanel starts logging events with one of the default IDs instead of the one I specified

In my opinion, priority should be given to the distinct ID that we specify, but this was the way they decided to handle it and there must be some reason for it I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants