# Import Mixpanel data to Google Sheets

Options for automatically importing Mixpanel data into Google Sheets.

April 29, 2025

# Use the official Mixpanel Google Sheets add-on

Mixpanel offers an [official Google Sheets add-on](https://workspace.google.com/marketplace/app/sheets_%E2%87%94_mixpanel/1078767167468) that allows you to sync data from your Mixpanel account to a Google Sheet.

This allows you to export reports or cohort data from your Mixpanel project and sync the data every hour if preferred. See the official documentation and instructions on how to install in the link above.

# Use Google Apps Script

[This Google Apps Script](https://github.com/melissaguyre/mixpanel-segmentation-google-spreadsheets) allows you to automatically fetch data from Mixpanel and bring it into a Google Sheet. Visit the repo linked above for full steps on how to use it.

Once installed, this script allows you to:

- Fetch data for any event and property  
- Trigger the script at a frequency you specify, such as every minute, hour, or day

## Visualizing Mixpanel formulas in your Google Sheet

It's possible to graph Mixpanel formulas using the Spreadsheets data source. Below are some examples and syntax information.

## Example formula

```
formulas=[\
     {\
          "queries": [\
               {"events": ["signup"], "count_type": "unique"},\
               {"events": ["Added User"], "count_type": "unique", "selector": "(properties[\"$os\"] == \"Mac OS X\") and \"y\" in properties[\"billing\"]"},\
          ],\
          "formula": "(A)/(B)"\
     }\
]
```

## Syntax

- `from_date`
- `to_date`
- `unit` – day, week or month
- `count_type` can be general, which means total, unique, or average
- `selector` is an expression, which you can learn more about from [Mixpanel's documentation](https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-expressions)

If you think of the queries as being labelled A to H (in the order they’re listed), then this is an expression of how to combine them.

There can be up to 4 elements in the numerator and up to 4 in the denominator, and it always looks like `(numerator)/(denominator)` – even if there’s only one thing there, e.g., (A)/(B).

The numerator and denominator are any valid mathematical expressions using `+`, `-`, `*` and `()`. For example `(A+(B-(C*D))/((E-F)*G+H)`.

The script could also be modified to use these parameters. You’d need to modify line 125 where the root API URL is defined (it’s hard-coded to use the `segmentation` endpoint). Then you'd need to modify how it handles the `API_PARAMETERS` e.g., line 193, which defines that the request should be sent with:

```
'event=' + parametersEntry[0],
        'where=' + parametersEntry[1],
        'type=' + parametersEntry[2],
        'unit=' + parametersEntry[3],
```

Where `parametersEntry` is defined as:

```
var parametersEntry = API_PARAMETERS[sheetName];
```
