Skip to content

Instantly share code, notes, and snippets.

@karol-blaszczyk
Last active December 31, 2015 01:59
Show Gist options
  • Save karol-blaszczyk/7918180 to your computer and use it in GitHub Desktop.
Save karol-blaszczyk/7918180 to your computer and use it in GitHub Desktop.
Mixpanel
mixpanel.register_once({
"initial referrer": document.referrer
});
- if user_signed_in?
:javascript
mixpanel.identify(#{current_user.try(:id)});
mixpanel.register_once({
$Email: "#{current_user.email}"
});
- if registation? || sign_in?
:javascript
mixpanel.people.set_once({
"$Created": "#{current_user.created_at}",
"$Last_login": "#{DateTime.now}", // properties can be dates...
$Email: "#{current_user.email}",
$First_name: "#{ current_user.contractor_profile.try(:first_name)}",
$Last_name: "#{ current_user.contractor_profile.try(:last_name)}",
$Priced_services: #{ current_user.try(:contractor_profile).try(:service_pricings).try(:count)},
$Company: #{ current_user.contractor_profile.try(:company)},
$Company_name: "#{ current_user.contractor_profile.try(:company_name)}",
$Description: "#{ current_user.contractor_profile.try(:description)}",
$Krs: "#{ current_user.contractor_profile.try(:krs)}",
$Nip: "#{ current_user.contractor_profile.try(:nip)}",
$Phone: "#{ current_user.contractor_profile.try(:phone)}",
$Phone_views_count: #{ current_user.contractor_profile.try(:phone_views_count)},
$Profile_views_count: #{ current_user.contractor_profile.try(:profile_views_count)},
$Skype_id: "#{ current_user.contractor_profile.try(:skype_id)}",
$Website: "#{ current_user.contractor_profile.try(:website)}",
$Postal_code: "#{ current_user.contractor_profile.try(:location_of_service).try(:postal_code)}",
$City: "#{ current_user.contractor_profile.try(:location_of_service).try(:city)}",
$Street: "#{ current_user.contractor_profile.try(:location_of_service).try(:street)}",
$Street_number: "#{ current_user.contractor_profile.try(:location_of_service).try(:street_number)}"
});
- if registation?]
:javascript
mixpanel.track("Sign_up", {
'Registration Referer': "#{URI( request.referer).path}",
$branch: "#{current_user.declared_branch.try(:name)}"
});
- if sign_in?
:javascript
mixpanel.track("Sign_in", {
$last_login: "#{DateTime.now}"
})
- if filled_up_profile_form?
:javascript
mixpanel.track("save contrator profile")
mixpanel.people.set({
$First_name: "#{ current_user.contractor_profile.try(:first_name)}",
$Last_name: "#{ current_user.contractor_profile.try(:last_name)}",
$Company: #{ current_user.contractor_profile.try(:company)},
$Company_name: "#{ current_user.contractor_profile.try(:company_name)}",
$Description: "#{ current_user.contractor_profile.try(:description)}",
$Krs: "#{ current_user.contractor_profile.try(:krs)}",
$Nip: "#{ current_user.contractor_profile.try(:nip)}",
$Skype_id: "#{ current_user.contractor_profile.try(:skype_id)}",
$Website: "#{ current_user.contractor_profile.try(:website)}",
$Postal_code: "#{ current_user.contractor_profile.try(:location_of_service).try(:postal_code)}",
$City: "#{ current_user.contractor_profile.try(:location_of_service).try(:city)}",
$Street: "#{ current_user.contractor_profile.try(:location_of_service).try(:street)}",
$Street_number: "#{ current_user.contractor_profile.try(:location_of_service).try(:street_number)}"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment