sparkartgroup-archive / sparkart.js

Easily interact with Sparkart's APIs via Javascript.
1 stars 0 forks source link

Properly Identify User when Mixpanel Initializes #52

Closed djiang closed 11 years ago

djiang commented 11 years ago

If a user first hits a page they randomly assigned a distinct_id for Mixpanel. However, this should only be happening for non-logged-in users. For a logged-in user, we should be using the Mixpanel.identify(customer_id) method so events get tracked to their existing accounts.

In sparkart.js, after Mixpanel is initialized:

loaded: function(){
    if( fanclub.customer ){
        mixpanel.identify(fanclub.customer.id);
    } else {
        fanclub.setMixpanelDistinctId();
    }
}

If a customer doesn't exist, we should send the generated Mixpanel distinct_id to the server, where it'll be aliased after checkout is complete. For Reference: https://mixpanel.com/docs/integration-libraries/javascript

djiang commented 11 years ago

Released