A simple server-side API for mixpanel
npm install mixpanel
// grab the Mixpanel factoryvar Mixpanel = ;// create an instance of the mixpanel clientvar mixpanel = Mixpanel;// track an event with optional propertiesmixpanel;mixpanel;// create or update a user in Mixpanel Engagemixpanelpeople;// create or update a user in Mixpanel Engage without altering $last_seen// - pass option `$ignore_time: true` to prevent the $last_seen property from being updatedmixpanelpeople;// set a single property on a usermixpanelpeople;// increment a numeric propertymixpanelpeople;// increment a numeric property by a different amountmixpanelpeople;// increment multiple propertiesmixpanelpeople;// append value to a listmixpanelpeople;// append multiple values to a listmixpanelpeople;// merge value to a list (ignoring duplicates)mixpanelpeople;// merge multiple values to a list (ignoring duplicates)mixpanelpeople;// record a transaction for revenue analyticsmixpanelpeople;// clear a users transaction historymixpanelpeople;// delete a usermixpanelpeople;// Create an alias for an existing distinct idmixpanel;// all functions that send data to mixpanel take an optional// callback as the last argumentmixpanel;// import an old eventvar mixpanel_importer = Mixpanel;// needs to be in the system once for it to show up in the interfacemixpanel_importer;mixpanel_importer;// import multiple events at oncemixpanel_importer;
mixpanel-node is a server-side library, optimized for stateless shared usage; e.g.,
in a web application, the same mixpanel instance is used across requests for all users.
Rather than setting a
identify() calls like Mixpanel client-side
libraries (where a single Mixpanel instance is tied to a single user), this library
requires you to pass the
distinct_id with every tracking call. See
How do I get or set superproperties?
See the previous answer: the library does not maintain user state internally and so has no concept of superproperties for individual users. If you wish to preserve properties for users between requests, you will need to load these properties from a source specific to your app (e.g., your session store or database) and pass them explicitly with each tracking call.
# in the mixpanel directory npm install npm test
Heavily inspired by the original js library copyright Mixpanel, Inc. (http://mixpanel.com/)
Copyright (c) 2014-15 Mixpanel Original Library Copyright (c) 2012-14 Carl Sverre
Released under the MIT license. See file called LICENSE for more details.