Solved

Can't identify user without alias

  • 23 February 2020
  • 3 replies
  • 131 views

It says in the docs that existing users don’t need alias, just identify when mixpanel first sees them.

And yet mixpanel only seems to pick up one of my users when they are aliased first. For example, this works:

mixpanel.alias("fake"); 
mixpanel.identify("fake");
mixpanel.people.set({
"$email": "fake",
"$created": "2011-03-16 16:53:54"
});
mixpanel.track("P: Home");

But this doesn’t:

mixpanel.identify("fake");
mixpanel.people.set({
"$email": "fake",
"$created": "2011-03-16 16:53:54"
});
mixpanel.track("P: Home");

(In practice I had switched the word fake between both runs and tried the second run via VPN in case it wouldn’t let me overwrite the user fingerprint - still no joy).

Am I doing something wrong?

icon

Best answer by dizzydes 25 February 2020, 10:35

Ah, it works now.

For future reference if people make the same mistake I did, you need to call things in a specific order.

Here’s what is now working for me:

 mixpanel.track("P: Home");
// This now works
mixpanel.identify(uid);
mixpanel.people.set({
"$email": uid,
// Standard creation time during beta
"$created": "2020-02-20 12:00:00"
});

 

View original

3 replies

Userlevel 5
Badge +4

@dizzydes can you share when in your users journey you are calling alias and the identify call?  or Github post with your code? 

You are correct that alias is only needed to be called if you want to capture anonymous activity of a user when they first create an account. If you do not want the data of what a users does before creating an account, then only calling identify when your users logs-in to your app will be enough.
 

mixpanel.alias("fake");

mixpanel.identify("fake");

mixpanel.people.set({ "$email": "fake", "$created": "2011-03-16 16:53:54" });

mixpanel.track("P: Home");

Looking at the first block of code you shared, it looks like you are calling alias and identify on the same block, this can cause some identity management issues. To keep you identity management healthy, you would ideally want to call them seperately and alias only once.  

 

The ideal structure would be, when a user creates an account call:

mixpanel.alias("fake");

mixpanel.people.set({

"$email": "fake",

"$created": "2011-03-16 16:53:54"

});

mixpanel.track("Account Created");

 

When users comes back to your app to log-in

mixpanel.track("Log-in");

mixpanel.identify("fake");

 

Hope this helps! 

Thanks for your response, Stephanie.

I’m calling this on index.php, my homepage. As my users already exist I would likely be using the second flow (identity only). As it the first page they see after logging in, is index.php the right place to call this from (and then subsequently nowhere else as its sessionised)?

I’m still at a loss as to why its not working with indentify only, though.

Ah, it works now.

For future reference if people make the same mistake I did, you need to call things in a specific order.

Here’s what is now working for me:

 mixpanel.track("P: Home");
// This now works
mixpanel.identify(uid);
mixpanel.people.set({
"$email": uid,
// Standard creation time during beta
"$created": "2020-02-20 12:00:00"
});

 

Reply