Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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