Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify Mixpanel user actions that occured before login

Tags:

mixpanel

I’m having an issue with Mixpanel identification. I want to be able to track events logged before the user logs in and identify them as such.

Here’s an exemple. Louie opens the webpage and visits the “About” page. Using mixpanel.track('Visit About'), I’m able to log Louie’s anonymous visit. All is fine and dandy.

Louie decides to log in, and a mixpanel.identify(user.id) call identifies him — and subsequent events can be tracked back to Louie. However, the first event (“Visit About”) still shows up with a random, Mixpanel-set distinct ID and hasn’t been associated with Louie.

Is this behaviour expected? What can I do? Cheers

like image 406
Iso Avatar asked Jan 21 '16 16:01

Iso


People also ask

How does Mixpanel identify a user?

There will be an identifier on a user's device at the time that they are interacting with an application with Mixpanel. This identifier is referred to as the local distinct_id. The local distinct_id can be randomly generated, or it can be the assigned ID that is connected to the user after an identify call.

How do I track a new user on Mixpanel?

Simply add a 1st time filter to any event in any of our core reports to filter down the event to only the ones performed by a given user for the first time ever.

What is distinct ID in Mixpanel?

Mixpanel's distinct_id is a unique identifier that is connected to every event as an event property. A distinct_id is assigned to every user that is tracked, and it connects all of the events performed by an individual user.

What is alias in Mixpanel?

An alias is a new. value that will be interpreted by Mixpanel as an existing value. That. means that you can send messages to Mixpanel using the new value, and. Mixpanel will continue to use the old value for calculating funnels and.


2 Answers

You want alias.

From their Javascript API reference:

Use alias() when a unique ID is first assigned (registration), and use identify() to identify the user with that unique ID on an ongoing basis (e.g., each time a user logs in after registering). Do not call identify() at the same time as alias().

From your description, it sounds like, rather than viewing the "About" page anonymously and then logging in, Louie is viewing the "About" page anonymously and then signing up.

In that case, call alias when Louie signs up, and call identify when he logs in after that. That should associate the random, anonymous Mixpanel ID with Louie's new registered user ID.

Note: using this method will mean that, because Louie triggered an event anonymously and then logged in, Louie's anonymous id for that event will not be linked to his distinct id from logging in. If he had signed up after triggering the anonymous event, you would call alias, and they would be linked. This is a known limitation of Mixpanel, unfortunately. From their documentation:

This is the first time he's accessed your site from this device, so we assign a brand new distinct_id to him. He clicks around and then logs in. You should not call mixpanel.alias() in this situation - we haven't seen him on this device, but he is not a new user. ... Instead of calling mixpanel.alias() you should just call mixpanel.identify(). This will remap his phone activity to the original ID he used when signing up for your service, which is the most desirable outcome. This does mean that regrettably the events he fired before logging in will not be associated with him.

More about aliasing in Mixpanel here.

like image 76
Captain Delano Avatar answered Oct 15 '22 13:10

Captain Delano


It took them a while, but here it is...

It's called Mixpanel Identity merge and it should fix the whole problem of connecting the actions an anonymous user did before signing up /logging in

The new system improves the behavior of identify(), alias(), and adds a new event called $merge.
All pre-authentication activity can now be mapped back to a user The ID merge system makes it possible to link pre and post authenticated event streams under a single identifier. This eliminates “false-uniques”, ensuring the most accurate conversion and drop-off rates in funnels and flows. Previously, Mixpanel could only map pre-sign up activity back to a user who was later identified. Any activity a user did anonymously before signing in again could not be attributed to that user.

Here is the whole blog post

like image 40
luigi7up Avatar answered Oct 15 '22 13:10

luigi7up