Search code examples
ruby-on-rails-3mixpanel

Mixpanel distinct_id using Ruby and Javascript Library


I don't understand how to properly use distinct_id. I am trying to create a Mixpanel funnel using Rails. Currently I am doing this w/o using distinct_id and thus mixpanel trends are pretty accurate but funnel which depend upon unique user count doesn't appear to be working. How should I use distinct_id property to solve this problem?

I'm using BOTH the Javascript library and the Ruby library.

The funnels steps are:

1.) User invited 2.) Invited user receives invitation email and clicks invitation link 3.) Page loaded 4.) Open signup module 5.) Creates account


Solution

  • It would probably be easiest to send data only from Ruby (by the way, which Ruby library are you using?) since the link and account creation must be sent server-side.

    You will have to choose a distinct_id that will identify a user through this entire process. The easiest way is to just use the invitee's e-mail address. This has the additional benefit of being able to track other events and "people" data with that e-mail and associate it with the right user.

    The only tricky part is step 2. You will need to generate a link that looks like http://api.mixpanel.com/track/?data=...&ip=1&redirect=http://www.your-site.com/invitation to put inside the email as the invitation link.

    See the docs for more info about the redirect parameter.