Skip to content

Instantly share code, notes, and snippets.

@constantm
Created August 5, 2016 08:17
Show Gist options
  • Save constantm/ad6e71adadb81b3f31ea87af4374ccd1 to your computer and use it in GitHub Desktop.
Save constantm/ad6e71adadb81b3f31ea87af4374ccd1 to your computer and use it in GitHub Desktop.
def candidate_analytics_track(user)
# Alias user on Mixpanel so we can track unique visits -> signup
if cookies['visit_id']
Analytics.alias(previous_id: cookies[:visit_id], user_id: user._id.to_s)
Analytics.flush # We need this to prevent race conditions and split profiles on Mixpanel
cookies.delete :visit_id
end
Analytics.identify(
user_id: "#{user._id}",
traits: {
email: "#{user.email }",
name: "#{user.profile.name}",
created_at: "#{user.created_at}",
type: "user"
# more properties here
})
Analytics.track(
user_id: "#{user._id}",
event: "signup-candidate")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment