Print

Import Mixpanel Data to Google Sheets

In this guide, we’ll walk through how to import Mixpanel data directly into Google Sheets, using the API Connector add-on for Sheets.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Get Your Access Token

  1. Log into Mixpanel and navigate to Settings > Organization Settings
    mixpanel-orgsettings
  2. Now click Service Accounts > +Add Service Account
    mixpanel-addserviceaccount
  3. You'll be prompted to select a name, roles, and expiration time for the Service account. Click Create.
    mixpanel-createserviceaccount
  4. You'll be presented with a modal containing your username and secret. Copy these down.
    mixpanel-credentials
  5. One last step: Because the Mixpanel API requires Basic Authentication, we need to encode our authentication info to base 64. You can do this by entering your your credentials in the format username:secret into this form (i.e. your username, then a colon, and then your secret).

    The encoding script runs in your browser, and none of your credentials are seen or stored by this site.

     

Part 2: Get Your Mixpanel Project ID

Most of Mixpanel's API endpoints require a project ID, so let's get that now. Click Settings > Project Settings and copy down the Project ID value.

While you're here, also note the value in the Data Residency field. If it says US, your API request URL will start with https://mixpanel.com while if it says EU, it will start with https://eu.mixpanel.com.

Part 3: Get Mixpanel Insights Data in Sheets

You can create a request using any of the endpoints and parameters described in Mixpanel's API documentation. For this example we'll get data from your Insights reports. For this endpoint you'll also need the report's bookmark ID, which can be found from the url: https://mixpanel.com/report/1/insights#report/your_bookmark_id/example-report. Substitute in your own encoded credentials from part 1 above.

  • Application: Custom
  • Method: GET
  • Request URL: https://mixpanel.com/api/2.0/insights?project_id=your_project_id&bookmark_id=your_bookmark_id
  • Headers
    • Authorization: Basic your_encoded_credentials

Notes:

  1. If your organization's data residency is in the EU, the API request URL will start with https://eu.mixpanel.com instead of https://mixpanel.com.
  2. Data for Mixpanel's /insights endpoint is currently returned in one long row, with each date receiving a unique column. This is due to the structure of the underlying JSON, as each date is a unique JSON key (and unique keys correspond to unique column headers). In the future, API Connector will add an option to restructure Mixpanel's response such that dates can be sorted into rows instead of columns.

Part 4: API Documentation

Official documentation: https://developer.mixpanel.com/reference/overview

Leave a Comment

Jump To