Solved

Wrong distinct_id in live view, am I doing something wrong?


Hello all,

 

I’m having some difficulties with updating my distinct_id using the identify() function using the node.js library.

 

 

Before tracking an event I am updating the identity using:

mixpanel.identify(user_id); 

It appears the distinct Id is set correctly as I am subsequently logging the output of,

mixpanel.get_distinct_id();

which I can confirm matches the user_id.

 

I then immediately track an event, however the distinct_id appearing in the live view is instead a long auto-generated distinct_id.

 

Has anyone encountered anything similar, or spot something fundamentally wrong with my implementation?

 

Thank you!

 

 

icon

Best answer by stephanie 7 May 2020, 23:30

Hi @tlittle,

We currently do not have an official public React Native library at the moment (coming soon!).  Not sure if you are referring to a this third-party react native library? If so, to be honest I am not familiar with this library and would not know how it works as my expertise is on Mixpanel’s libraries.

I can speak generally on how client-side libraries such as Javascript or iOS work in hopes that it might help with managing your user_id within the react native library on your app. As you have noticed, our client-side libraries will assign their own random distinct_id if none is set. If you are setting your own unique id on a client-side library, it works similarly to back-end in library in the sense that you will now need to “attach” the unique id you are setting to the events that are being sent in to keep it consistent.

You are on the right path on passing your user_id through the identify call. Additionally, since you are setting your own user_id you now have to set the user_id to every event, this can be done by using super properties via the identify functions. I wanted to share our help article Assigning Your Own UniqueID to Users which talks in more details on how super properties can help manage your user_id when working with client-side libraries.

Let me know if this helps!

View original

3 replies

Userlevel 5
Badge +4

Hi @tlittle

Going of what you have shared, I think it is worth mentioning that our  Mixpanel-node library requires you to pass the distinct_id with every event tracking call. Since you have to set the distinct_id with every event on Mixpanel-node,  there is no concept of an identify call (more information here). 

In order to send an event with the distinct_id that you want, you need to pass it within the event.track call.

Example code here: 

var Mixpanel = require('mixpanel');
var mixpanel = Mixpanel.init('<YOUR_TOKEN>');

// track an event and pass unique client id with it
mixpanel.track('event name', {
distinct_id: 'unique client id',
property_1: 'value 1',
property_2: 'value 2',
property_3: 'value 3'
});

Once you send this event in along with your distinct_id, you should see the distinct_id value you set and can confirm this in live view. 

 

You may have seen this  already but just in case wanted to pass along our help article on identity management on hybrid implementations which might be helpful to reference as you continue to use Mixpanel. 

 

Hope this helps understand what you are seeing!

Good morning Stephanie,

I’m having some difficulties with updating my distinct_id using the identify() function using the node.js library.

 

Sorry, I mistyped. My implementation is in fact using the react-native-mixpanel library.

 

As I understand in this library, the identify function should set the current distinct_id and no parameter is needed in the actual track call. Is this correct?

 

Thanks,

Tom

Userlevel 5
Badge +4

Hi @tlittle,

We currently do not have an official public React Native library at the moment (coming soon!).  Not sure if you are referring to a this third-party react native library? If so, to be honest I am not familiar with this library and would not know how it works as my expertise is on Mixpanel’s libraries.

I can speak generally on how client-side libraries such as Javascript or iOS work in hopes that it might help with managing your user_id within the react native library on your app. As you have noticed, our client-side libraries will assign their own random distinct_id if none is set. If you are setting your own unique id on a client-side library, it works similarly to back-end in library in the sense that you will now need to “attach” the unique id you are setting to the events that are being sent in to keep it consistent.

You are on the right path on passing your user_id through the identify call. Additionally, since you are setting your own user_id you now have to set the user_id to every event, this can be done by using super properties via the identify functions. I wanted to share our help article Assigning Your Own UniqueID to Users which talks in more details on how super properties can help manage your user_id when working with client-side libraries.

Let me know if this helps!

Reply