How do I tell mixpanel the userID of my logged on user?
Do I need to call mixpanel.people.identify()
everytime my user logs in, or only the first time that I'm creating them on mixpanel?
If only the first time, how does mixpanel know who to associate events to?
Also, once I have identified the person, will all events be tracable to that person, or do I need to call people.set()
explicitly to track a generic event separately from a user-specific event?
You should call mixpanel.people.identify()
every time a user logs in. You can even call it every time a page loads in a logged in state if you want.
identify
sets some data in a cookie about what distinct_id
the library should use when sending people data.
If you have called events that you send (with mixpanel.identify
with the same distinct_id
as mixpanel.people.identify
,mixpanel.track
) will show up under the user's profile on the Customers tab. In order for the user to show up at all, though, you will need to call mixpanel.people.set
(or .add
) at least once.
EDIT: mixpanel.people.identify
is no longer necessary; you can just call mixpanel.identify
and it will set both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With