Solved

Where to call alias()?

  • 9 February 2019
  • 1 reply
  • 124 views

Userlevel 2
Badge

My team and I are trying to integrate Segment into our site in a way that's compatible with Mixpanel. We are tracking page views with Segment's clientside Javascript library and user events with their backend Python library. Mixpanel requires that, when a user signs up, we make an alias() call from the frontend before we can make an identify() call. We're having trouble figuring out where this alias() call should be made from.

Our application is fairly complicated, with sign up forms in multiple places (some are in React, some are in Django). We also do not have any kind of "welcome" landing page that the user is redirected to after they make an account. Right now they're just redirected to the home page, which is how we would prefer to keep it. But this redirect doesn't allow us to conditionally make the Javascript alias() call from the home page after sign up. We could add a query to the redirect url with some boolean property that triggers the call, but we're considering that as a last resort.

My question is: if we aren't using a "welcome" page, where should we make this alias() call from?

Thank you.


icon

Best answer by admin 9 February 2019, 04:56

Hi - here are a few ideas... maybe it can help you get on the right track:

1. As you mentioned, if the user is new, add something like `?registered=true` to the homepage. On the homepage, check for that param. If found, call alias() and remove the parameter so they don't refresh it and call it again.


If you really don't want to use a URL query string, you could achieve the same thing with localStorage or cookies.


2. Can you call alias before redirecting? You mentioned it's a single-page-app, so I imagine that once they register you can call alias() and then redirect them to your homepage.


3. Can you check the referring URL from the homepage to see if it was a registration page?


View original

1 reply

Userlevel 4
Badge

Hi - here are a few ideas... maybe it can help you get on the right track:

1. As you mentioned, if the user is new, add something like `?registered=true` to the homepage. On the homepage, check for that param. If found, call alias() and remove the parameter so they don't refresh it and call it again.


If you really don't want to use a URL query string, you could achieve the same thing with localStorage or cookies.


2. Can you call alias before redirecting? You mentioned it's a single-page-app, so I imagine that once they register you can call alias() and then redirect them to your homepage.


3. Can you check the referring URL from the homepage to see if it was a registration page?


Reply