Skip to content

Instantly share code, notes, and snippets.

@MeryllEssig
Forked from LeCoupa/mixpanel-cheatsheet.js
Created August 28, 2017 15:11
Show Gist options
  • Select an option

  • Save MeryllEssig/57a8ffbfa31571cf3f28a33edd1ae10d to your computer and use it in GitHub Desktop.

Select an option

Save MeryllEssig/57a8ffbfa31571cf3f28a33edd1ae10d to your computer and use it in GitHub Desktop.
Mixpanel Library CheatSheet
// Mixpanel Cheatsheet
// This requires the mixpanel javascript library to be embedded on your site
// https://mixpanel.com/help/reference/javascript-full-api-reference
mixpanel.init('new token', { your: 'config' }, 'library_name'); // initialize a new instance of the Mixpanel tracking object
mixpanel.push(['register', { a: 'b' }]); // push() keeps the standard async-array-push behavior around after the lib is loaded. This is only useful for external integrations that do not wish to rely on our convenience methods (created in the snippet). Good example is Optimizely.
mixpanel.disable('eventToDisable'); // Disable events on the Mixpanel object. If passed no arguments, this function disables tracking of any event. If passed an array of event names, those events will be disabled, but other events will continue to be tracked.
mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21}, callback); // Track an event.
mixpanel.track_links('#nav', 'Clicked Nav Link', {'Gender': 'Male', 'Age': 21}); // Track clicks on a set of document elements.
mixpanel.track_forms('#register', 'Created Account', {'Gender': 'Male', 'Age': 21}); // Tracks form submissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment