By Rudderstack Team

How to load data from Mixpanel to Google BigQuery

This post helps you with loading your data from Mixpanel to BigQuery. If you are looking to get analytics-ready data without the manual hassle you can integrate Mixpanel to BigQuery with RudderStack, so you can focus on what matters, getting value out of your data.

What we will see:

  1. An Intro to Google BigQuery and Mixpanel.
  2. Extract your data from Mixpanel and Mixpanel API (the hard way).
  3. Prepare your Mixpanel data for Google BigQuery.
  4. Load from Mixpanel to BigQuery.
  5. The best way to load from Mixpanel to Google BigQuery (the easy way).

Extract data from Mixpanel

Mixpanel is an analytics-as-a-service application so naturally, it requires data to offer its analytics features. We usually think of it as a consumer of data and not a place where we would get data out of, in order to perform the analysis. But Mixpanel collects a lot 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 by 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 any data Mixpanel holds for you and load it on a data warehousing repository for further analysis. In this post, I will consider the second case.

Mixpanel is evolving into a platform where apart from the analytics services that it offers, you will also be able to build applications that are integrated with it. In this post, we will work only with the Export API which purpose is to allow us to export our data from Mixpanel.

As a web API, you can access it by using tools like CURL or Postman or your favorite http client for the language or framework of your choice. Some options are the following:

Or you can use the libraries/SDKs that Mixpanel offers for the following languages:

  • Python
  • PHP
  • Ruby
  • Javascript

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 specific time period


  • events– get total, unique, or average data for a set of events during 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 by 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 in 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 period of time
  • numeric– get numeric data, divided up into buckets for an event segmented and filtered by properties over a time period
  • 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 coming from People Analytics

Let’s assume that we want to export our raw data coming from Mixpanel. To do so we’ll need to execute requests to the export endpoint. An example of a request that would get us back raw events from Mixapanel looks like this: &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 originating from the export API are updated every 24 hours, so you will always have access to the data by the previous day.

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

About Mixpanel

Mixpanel helps businesses grow by helping them understand 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 gives you the ability to easily measure what people are doing in your app on iOS, Android, and the web.

Prepare your Mixpanel Data for Google BigQuery

Before you load your data into BigQuery, you should make sure that it is presented in a format supported by it, so for example if the API you pull data out of returns XML you have to first transform it into a serialization that BigQuery understands. Currently, two data formats are supported:

You also need to make sure that the data types you are using are the ones supported by BigQuery, which are the following:


For more information please check the Preparing Data for BigQuery page on the documentation.

About Google BigQuery

BigQuery is the data warehousing solution of Google. It’s part of the Google Cloud Platform and it also speaks SQL like Redshift does. Queries are executed against append-only tables using the processing power of Google’s infrastructure. It is also fully managed and is offered as a service over the cloud. You are able to interact with it through its web UI, using a command line tool while a variety of client libraries exist so you interact with it through your application.

Load from Mixpanel to Google BigQuery

If you want to load data out of Mixpanel to Google BigQuery, you have to use one of the following supported data sources.

  1. Google Cloud Storage
  2. Sent data directly to BigQuery with a POST request
  3. Google Cloud Datastore Backup
  4. Streaming insert
  5. App Engine log files
  6. Cloud Storage logs

From the above list of sources, 5 and 6 are not applicable in our case.

For Google Cloud Storage, you first have to load your data into it, there are a few options on how to do this, for example you can use the console directly as it is described here and do not forget to follow the best practices. Another option is to post your data through the JSON API, as we see again APIs play an important role in both the extraction but also the loading of data into our data warehouse. In its simplest case, it’s just a matter of one HTTP POST request using a tool like CURL or Postman. It should look like the following example.

POST /upload/storage/v1/b/myBucket/o?uploadType=media&name=myObject HTTP/1.1 Host: Content-Type: application/text Content-Length: number_of_bytes_in_file Authorization: Bearer your_auth_token your Mixpanel data

and if everything went ok, you should get something like the following as a response from the server:

HTTP/1.1 200 Content-Type: application/json { "name": "myObject" }

Working with Curl or Postman is good only for testing, in case you want to automate the process of loading your data into Bigquery, you should write some code to send your data to Google Cloud Storage. In case you are developing on the Google App Engine you can use the library that is available for the languages that are supported by it:

  1. Python
  2. Java
  3. PHP
  4. Go

If you are using one of the above languages and you are not coding for the Google App Engine, you can use it to access the Cloud Storage from your environment. Interacting such a feature-rich product like Google Cloud Storage can become quite complicated depending on your use case, for more details on the different options that exist you can check Google Cloud Storage documentation. If you are looking for a less engaged and more neutral way of using Storage in the Cloud, you can consider a solution like RudderStack.

After you have loaded your data into Google Cloud Storage, you have to create a Load Job for BigQuery to actually load data into it, this Job should point to the source data in Storage on the Cloud that have to be imported, this happens by providing source URIs that point to the appropriate objects.

The previous method described, used a POST request to the Google Cloud Storage API for storing the data there and then load it into BigQuery. Another way to go is to do a direct HTTP POST request to BigQuery with data you would like to query. This approach is similar to how we loaded any data to Cloud in the Google Storage through the JSON API, but it uses the appropriate end-points of BigQuery to load every data there directly. The way to interact with it is quite similar, for more information can be found on the BigQuery API Reference and on the page that describes how you can load data into BigQuery using POST. You can interact with it using the HTTP client library of the language or framework of your choice, a few options are:

The Best way to Load Data from Mixpanel to BigQuery

So far, we just scraped the surface of what you can do with BigQuery and you can load data into it. Things can get even more complicated if you want to integrate data coming from different sources.

Are you striving to achieve results right now?

Instead of writing, hosting, and maintaining a flexible data infrastructure use RudderStack that can handle everything automatically for you.

RudderStack with one click integrates with sources or services, creates analytics-ready data, and syncs your Mixpanel to BigQuery right away.

Help your product and product team combine customer event data that live in Mixpanel with Sales or Billing to supercharge your product insights.

RudderStack is the easiest way to automate powerful data integrations.

Try RudderStack Free Today