Log in


How to load data from Mixpanel to SQL Data Warehouse

01. About

  • 01. About
  • 02. Extract Data from Mixpanel
  • 03. Load Data
  • 04. Extract Data

Try RudderStack for free

Sign up for RudderStack for free.

Let’s suppose you decide you want to analyze the data you have on Mixpanel and do that on SQL Data Warehouse. This guide helps you define a pipeline for getting your data from Mixpanel and load it into SQL Data Warehouse for further analysis. Alternatively, you can use products like RudderStack that can handle this kind of problem automatically for you.

Information will be given on how to access and extract your data from Mixpanel through its API and how to load it into SQL Data Warehouse. This process requires you to write the code to get the data and make sure that this process will run every time new data is generated.

Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.

About Microsoft Azure SQL Data Warehouse

SQL Data Warehouse is the data warehousing solution you can use if you are a Microsoft Azure user. It’s an elastic data warehousing as a service solution, emphasizing its enterprise focus. It also speaks SQL like the previous two solutions, and it supports querying both relational and non-relational data. It offers a number of enterprise-class features like support for hybrid cloud installations and strong security. It’s probably the less mature solution than the two others though, it’s still in Preview mode although accessible to existing Azure subscribers.

About Mixpanel

Mixpanel helps businesses grow by understanding how their users behave and use their products by tracking actions people take rather than page views. Mixpanel’s mission is to help the world learn from its data. It helps you to make your product better by measuring actions instead of page views. Mixpanel allows you to easily measure what people are doing in your app on iOS, Android, and the web.

Extract data from Mixpanel

Mixpanel is an analytics-as-a-service application, so it requires data to offer its analytics features. Mixpanel collects huge amounts of data related to how your customers use your product, and in the case where you would like to do anything that also involves data from other sources you really have two choices. The first one is to enrich the data of Mixpanel with data coming from other sources and the second one is to extract the data Mixpanel holds for you and load it on a data warehousing repository for further analysis. This post will consider the second case.

Along with the analytics services, Mixpanel also enables you to build applications integrated with it. In this post, we will work only with the Export API to export our data from Mixpanel.

As a web API, you can access it using tools like CURL or Postman or your favorite HTTP client for the language or framework of your choice. You can choose from the options given below:

You can also use the libraries/SDKs that Mixpanel offers for the following languages:

As a RESTful API, it offers the following resources that you can interact with:


  • annotations– list the annotations for a specified date range.
  • create– create an annotation
  • update– update an annotation
  • delete– delete an annotation


  • export– get a “raw dump” of tracked events over a time period


  • events– get total, unique, or average data for a set of events over a time period
  • top– get the top events from the last day
  • names– get the top event names for a time period

Event Properties

  • properties– get total, unique, or average data from a single event property
  • top– get the top properties for an event
  • values– get the top values for a single event property


  • funnels– get data for a set of funnels over a time period
  • list– get a list of the names of all the funnels


  • segmentation– get data for an event, segmented and filtered by properties over a time period
  • numeric– get numeric data, divided up into buckets for an event segmented and filtered by properties over a period of time
  • sum– get the sum of a segment’s values per time unit
  • average– get the average of a segment’s values per time unit
  • Segmentation Expressions– a detailed overview of what a segmentation expression consists of


  • retention– get data about how often people are coming back (cohort analysis)
  • addiction– get data about how frequently people are performing events

People Analytics

  • engage– get data from People Analytics

Let’s assume we want to export our raw data from Mixpanel. To do so, we’ll need to execute requests to the export endpoint. An example request to get raw events from Mixpanel is as follows:

SH &to_date=2012-02-14&api_key=f0aa346688cee071cd85d857285a3464& where=properties%5B%22%24os%22%5D+%3D%3D+%22Linux%22&event=%5B%22Viewed+report%22%5D

The returned result is always in JSON serialization with one event per line sorted by increasing timestamp. It looks like the following sample:

{"event":"Viewed report", "properties":{"distinct_id":"foo","time":1329263748,"origin":"invite", "origin_referrer":"","$initial_referring_domain":"", "$referrer":"","$initial_referrer":"", "$referring_domain":"","$os":"Linux","origin_domain":"","tab":"stream", "$browser":"Chrome","Project ID":"3","mp_country_code":"US"}}

Important: Data from the export API is updated every 24 hours, so you will always have access to the data from the previous day.

After you extract all the information you need, you have to map it to your data warehouse repository schema and then load the data to it following the instructions of this post.

Load Data from Mixpanel to SQL Data Warehouse

SQL Data Warehouse support numerous options for loading data, such as:

  • PolyBase
  • Azure Data Factory
  • BCP command-line utility
  • SQL Server integration services

To Load data from online services by using their exposed HTTP APIs, we will not consider the usage of BCP command-line utility or SQL server integration in this guide. Instead, we'll consider the case of loading our data as Azure storage Blobs and then use PolyBase to load the data into SQL Data Warehouse.

Accessing these services happens through HTTP APIs and APIs play an important role in both the extraction but also the loading of data into our data warehouse. You can access these APIs by using a tool like CURL or Postman or use the libraries provided by Microsoft for your favorite language. Before you actually upload any data you have to create a container which is something similar to a concept to the Amazon AWS Bucket, creating a container is a straightforward operation and you can do it by following the instructions found on the Blog storage documentation from Microsoft. As an example, the following code can create a container in Node.js.

blobSvc.createContainerIfNotExists('mycontainer', function(error, result, response){ if(!error){ // Container exists and allows // anonymous read access to blob // content and metadata within this container } });

After the creation of the container you can start uploading data to it by using again the given SDK of your choice in a similar fashion:

blobSvc.createBlockBlobFromLocalFile('mycontainer', 'myblob', 'test.txt', function(error, result, response){ if(!error){ // file uploaded } });

When you are done putting your data into Azure Blobs you are ready to load it into SQL Data Warehouse using PolyBase. To do that you should follow the directions in the Load with PolyBase documentation. In summary, the required steps to do it, are the following:

  • create a database master key
  • create a database scoped credentials
  • create an external file format
  • create an external data source

PolyBase’s ability to transparently parallelize loads from Azure Blob Storage will make it the fastest tool for loading data. After configuring PolyBase, you can load data directly into your SQL Data Warehouse by simply creating an external table that points to your data in storage and then mapping that data to a new table within SQL Data Warehouse.

You will need to establish a recurrent process that will extract any newly created data from your service, load them in the form of Azure Blobs and initiate the PolyBase process for importing the data again into SQL Data Warehouse. One way of doing this is by using the Azure Data Factory service. In case you would like to follow this path you can read some good documentation on how to move data to and from Azure SQL Warehouse using Azure Data Factory.

The best way to load data from Mixpanel to SQL Data Warehouse and possible alternatives

So far we just scraped the surface of what can be done with Microsoft Azure SQL Data Warehouse and how to load data into it. The way to proceed relies heavily on the data you want to load, from which service they are coming from, and the requirements of your use case. Things can get even more complicated if you want to integrate data coming from different sources. A possible alternative, instead of writing, hosting, and maintaining a flexible data infrastructure, is to use a product like RudderStack that can handle this kind of problem automatically for you.

RudderStack integrates with multiple sources or services like databases, CRM, email campaigns, analytics, and more. Quickly and safely move all your data from Mixpanel into SQL Data Warehouse and start generating insights from your data.

Sign Up For Free And Start Sending Data

Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.

Get Started Image

Get started today

Start building smarter customer data pipelines today with RudderStack. Our solutions engineering team is here to help.

Customer Data Platform for Developers | RudderStack
HIPPA Compliant
SOC 2 TYPE 2Users love RudderStack on G2