How can I export my raw data from Mixpanel?
This article covers exporting data programmatically via Mixpanel’s API.
Mixpanel API endpoints
The first step to exporting your data from Mixpanel is choosing the API endpoint you need to use depending on what data you need:
Raw export API: Provides a full export of your raw Event data; i.e., instead of returning the number of users who performed an action on a given day like a Mixpanel report would, it returns all instances of that action and all associated properties with each action.
Engage API: Provides access to Mixpanel People data, including all users with their associated people properties.
Shortcuts for exporting data
This Gist contains a sample Python script that downloads raw event data from the /export/ API endpoint and writes it to a file.
This Gist contains a sample Python script that downloads People data from the /engage/ API endpoint and writes it to a file.
Set up an ETL (Extract, Transform, and Load) configuration
Once you’ve exported your data, you can manipulate the response before sending it on to another platform - i.e., grab the specific part of the data you need from the response. For example, if you’re exporting People data to MailChimp to sync user unsubscribe status, you can look for a user’s email address and the value of the $unsubscribed key in a People export.
Once you grab desired data from the dataset and format the data appropriately, you would then hit another API such as MailChimp or Salesforce to add this Mixpanel data into the other platform in the relevant format for that platform.
The best way to automate this process is to first run tests until a working ETL model is built between Mixpanel and the final data location. Once you’ve built a successful test model, you can automate the process to run at desired intervals (with a cron or scheduled job).
For example, your crontab file for the example above might contain an entry like:
# start the Mixpanel ETL job daily at 6am server time 0 6 * * * /usr/bin/mixpanel_to_mailchimp_etl.py