Skip to content

Instantly share code, notes, and snippets.

@cmorss
Created June 24, 2013 21:36
Show Gist options
  • Save cmorss/5853811 to your computer and use it in GitHub Desktop.
Save cmorss/5853811 to your computer and use it in GitHub Desktop.
# Our app is a backbone.js app, so no 'normal' page loads.
class App.Actions
# Our version of identify to deal with logged in vs anonymous users.
identify: (options = {}) =>
callback = options.callback
delete options.callback
# Is the user logged in?
if App.user
attrs = _.extend attrs,
email : App.user.get("email")
# set a bunch of other user specific properties
analytics.identify App.user.get("id"), attrs, callback
else
analytics.identify attrs, callback
# Actions#register is called right after a user successfully logs in.
register: (options) =>
analytics.alias App.user.get("id")
func = =>
@trackGAConv()
@identify callback: =>
analytics.track 'Registered' # This is the first event we see for this user in MixPanel
# Do this delay to make sure the alias has happened. Problem?
_.delay func, 500
@cmorss
Copy link
Author

cmorss commented Jun 24, 2013

For signed in it looks like this:

  signedIn: (options) =>
    @identify callback: =>
      analytics.track 'Signed In'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment