# Mixpanel on boxd

> Mixpanel is a product analytics platform tracking user interactions and engagement, providing cohort analysis, funnels, and A/B testing to improve user experiences.

- Page: https://boxd.sh/integrations/mixpanel/
- CLI: `run mixpanel` (50 commands, 22 marked common)
- SDK: `import { mixpanel } from "@boxd/run"`; every parameter and response type is at `@boxd/run/mixpanel`
- Triggers: none
- Connect: `run auth mixpanel` (API key), or https://app.boxd.sh/integrations/detail/mixpanel
- All integrations: https://boxd.sh/integrations/ (Markdown: https://boxd.sh/integrations/index.md)

## From the shell

```sh
run auth mixpanel      # once: prints a link to connect your account
run mixpanel           # list its commands
run mixpanel get-all-projects
```

Parameters are flags (`--flag value`); object and array parameters take a JSON string. Output is YAML, or JSON with `--json`. Calls use your own connection; `--scope <name>` uses a connection shared with your team.

## From a script

```ts
import { every, mixpanel } from "@boxd/run";

every("1 hour", async () => {
  const result = await mixpanel.getAllProjects();
  console.log(result);
});
```

Run it with `run mixpanel.run.ts`. Mixpanel has no triggers; `every()` polls on a schedule, keeps the script running as a job, and wakes the machine when it is due.

## Commands

Required flags are listed; `run mixpanel <command> --help` lists the optional ones. "common" marks what `run mixpanel` shows without `--all`.

| Command | SDK method | Required flags | Optional | Description |
|---|---|---|---|---|
| `add-unique-to-profile-list-property` | `mixpanel.addUniqueToProfileListProperty()` | `--data` | 4 | Add unique values to list properties on user profiles in Mixpanel using the $union operation |
| `aggregate-event-counts` ·common ·deprecated | `mixpanel.aggregateEventCounts()` | `--event` `--project-id` `--type` `--unit` | 5 | Use aggregate-events instead |
| `aggregate-events` | `mixpanel.aggregateEvents()` | `--from-date` `--project-id` `--to-date` | 8 | Get aggregate event counts over time |
| `aggregated-event-property-values` | `mixpanel.aggregatedEventPropertyValues()` | `--event` `--name` `--project-id` `--type` `--unit` | 7 | Get unique, total, or average data for a single event and property over days, weeks, or months |
| `cohorts-list` ·common | `mixpanel.cohortsList()` | `--project-id` | 1 | List all saved cohorts in a Mixpanel project |
| `create-annotation-tag` | `mixpanel.createAnnotationTag()` | `--name` `--project-id` | 0 | Create a new annotation tag in Mixpanel using the provided name |
| `create-identity` | `mixpanel.createIdentity()` | `--anon-id` `--identified-id` `--token` | 2 | Create an identity mapping in Mixpanel by linking an anonymous ID with an identified user ID |
| `create-service-account` ·common | `mixpanel.createServiceAccount()` | `--organization-id` `--username` | 3 | Create a new service account for your organization and optionally add it to projects |
| `delete-group` | `mixpanel.deleteGroup()` | `--group-id` `--group-key` `--token` | 1 | Permanently delete a group profile from Mixpanel Group Analytics |
| `delete-profile` | `mixpanel.deleteProfile()` | `--distinct-id` `--token` | 3 | Permanently delete a user profile from Mixpanel, along with all of its properties |
| `delete-profile-batch` | `mixpanel.deleteProfileBatch()` | `--profiles` | 0 | Permanently delete multiple user profiles from Mixpanel in a single batch request |
| `delete-profile-property` | `mixpanel.deleteProfileProperty()` | `--distinct-id` `--token` `--unset` | 4 | Permanently delete properties from a Mixpanel user profile using the $unset operation |
| `get-all-projects` ·common | `mixpanel.getAllProjects()` | — | 0 | Get all projects associated with the authenticated Mixpanel account |
| `get-annotation-tags-alt1` | `mixpanel.getAnnotationTagsAlt1()` | `--project-id` | 0 | Get all annotation tags from a Mixpanel project |
| `group-batch-update` ·common | `mixpanel.groupBatchUpdate()` | `--data` | 1 | Send a batch of group profile updates to Mixpanel |
| `group-delete-property` | `mixpanel.groupDeleteProperty()` | `--group-id` `--group-key` `--properties` `--token` | 0 | Delete specific properties from a Mixpanel group profile |
| `group-set-property` ·common ·deprecated | `mixpanel.groupSetProperty()` | `--groups` | 0 | Use group-batch-update instead |
| `identity-create-alias` | `mixpanel.identityCreateAlias()` | `--alias` `--distinct-id` `--token` | 0 | Create an alias mapping between two distinct IDs in Mixpanel |
| `jql-query` ·common | `mixpanel.jqlQuery()` | `--project-id` `--script` | 2 | Execute a custom JQL (JavaScript Query Language) query against Mixpanel's Query API |
| `list-cohorts` ·common ·deprecated | `mixpanel.listCohorts()` | `--project-id` | 1 | Use MIXPANEL_MIXPANEL_COHORTS_LIST instead |
| `list-funnels` ·common | `mixpanel.listFunnels()` | `--project-id` | 1 | Get the names and funnel_ids of your funnels |
| `list-saved-cohorts` ·common ·deprecated | `mixpanel.listSavedCohorts()` | `--project-id` | 0 | Use MIXPANEL_MIXPANEL_COHORTS_LIST instead |
| `list-service-accounts` ·common | `mixpanel.listServiceAccounts()` | `--organization-id` | 0 | List all service accounts for an organization |
| `profile-append-to-list-property` | `mixpanel.profileAppendToListProperty()` | `--data` | 1 | Append values to list properties on user profiles in Mixpanel |
| `profile-batch-update` ·common | `mixpanel.profileBatchUpdate()` | `--profiles` | 0 | Update multiple user profiles in Mixpanel in a single batch request |
| `profile-delete-property` ·deprecated | `mixpanel.profileDeleteProperty()` | `--distinct-id` `--token` `--unset` | 4 | Use delete-profile-property instead |
| `profile-event-activity` ·common | `mixpanel.profileEventActivity()` | `--distinct-ids` `--from-date` `--project-id` `--to-date` | 1 | Get event activity feed for specified users from Mixpanel Query API |
| `profile-numerical-add` | `mixpanel.profileNumericalAdd()` | `--add` `--distinct-id` `--token` | 4 | Increment or decrement numerical properties on user profiles in Mixpanel |
| `profile-remove-from-list-property` | `mixpanel.profileRemoveFromListProperty()` | `--data` | 1 | Remove values from list properties on user profiles in Mixpanel |
| `profile-set` ·common | `mixpanel.profileSet()` | `--distinct-id` `--set-properties` `--token` | 3 | Set user profile properties in Mixpanel using the $set operation |
| `query-frequency-report` | `mixpanel.queryFrequencyReport()` | `--addiction-unit` `--from-date` `--project-id` `--to-date` `--unit` | 5 | Get data about how frequently users are performing events |
| `query-funnel` ·common | `mixpanel.queryFunnel()` | `--from-date` `--funnel-id` `--project-id` `--to-date` | 8 | Get data for a funnel |
| `query-insight` ·common | `mixpanel.queryInsight()` | `--bookmark-id` `--project-id` | 1 | Get data from your Insights reports |
| `query-months-top-event-names` ·common ·deprecated | `mixpanel.queryMonthsTopEventNames()` | `--project-id` `--type` | 2 | Use top-events instead |
| `query-numeric-average` | `mixpanel.queryNumericAverage()` | `--event` `--from-date` `--on` `--project-id` `--to-date` | 3 | Averages an expression for events per unit time |
| `query-numeric-sum` | `mixpanel.queryNumericSum()` | `--event` `--from-date` `--on` `--project-id` `--to-date` | 3 | Sums an expression for events per unit time |
| `query-profiles` ·common | `mixpanel.queryProfiles()` | `--project-id` | 12 | Query user or group profile data from Mixpanel |
| `query-retention-report` | `mixpanel.queryRetentionReport()` | `--from-date` `--project-id` `--to-date` | 11 | Query cohort analysis showing user retention patterns over time |
| `query-segmentation` ·common | `mixpanel.querySegmentation()` | `--event` `--from-date` `--project-id` `--to-date` | 6 | Get data for an event, segmented and filtered by properties with daily/time-series breakdown |
| `query-top-events` ·common | `mixpanel.queryTopEvents()` | `--project-id` `--type` | 2 | Get the top events for today, with their counts and the normalized percent change from yesterday |
| `remove-from-group-list-property` | `mixpanel.removeFromGroupListProperty()` | `--data` | 0 | Remove values from list properties on group profiles in Mixpanel |
| `remove-from-list-property` | `mixpanel.removeFromListProperty()` | `--distinct-id` `--remove-properties` `--token` | 3 | Remove values from list properties on user profiles in Mixpanel using the $remove operation |
| `segmentation-numeric-query` ·common | `mixpanel.segmentationNumericQuery()` | `--event` `--from-date` `--on` `--project-id` `--to-date` | 5 | Get event data numerically bucketed by property values |
| `set-group-property-once` ·common | `mixpanel.setGroupPropertyOnce()` | `--group-id` `--group-key` `--properties` `--token` | 0 | Set properties on a Mixpanel group profile only if they don't already exist |
| `set-profile-property-once` | `mixpanel.setProfilePropertyOnce()` | `--distinct-id` `--set-once-properties` `--token` | 3 | Set user profile properties in Mixpanel using the $set_once operation |
| `todays-top-events` ·deprecated | `mixpanel.todaysTopEvents()` | `--project-id` `--type` | 2 | Use query-top-events instead |
| `top-event-properties` | `mixpanel.topEventProperties()` | `--event` `--project-id` | 2 | Get the top property names for an event |
| `top-event-property-values` | `mixpanel.topEventPropertyValues()` | `--event` `--name` `--project-id` | 2 | Get the top values for a property ordered by frequency |
| `top-events` | `mixpanel.topEvents()` | `--project-id` `--type` | 2 | Get a list of the most common events over the last 31 days |
| `update-group-list-property` | `mixpanel.updateGroupListProperty()` | `--data` | 3 | Add unique values to list properties on group profiles in Mixpanel |

## Docs

- [run CLI](https://docs.boxd.sh/cli/run): Call connected integrations from the shell, connect new ones, and run automations.
- [Quickstart](https://docs.boxd.sh/guides/integrations/quickstart): Connect an integration, call it from the shell, and turn a script into an automation.
- [Connections](https://docs.boxd.sh/guides/integrations/connections): Connect an account once, for yourself or for your whole organization.
- [Scripts](https://docs.boxd.sh/guides/automations/scripts): Typed integrations, triggers, schedules and state in a .run.ts file.
- [Jobs](https://docs.boxd.sh/guides/automations/jobs): How a script becomes a background job: states, retries, sleep and wake.
- [Beyond the catalog](https://docs.boxd.sh/guides/automations/beyond-the-catalog): Reach your own APIs, databases and cloud accounts from a script.
