> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Mixpanel

> Learn how to integrate AI agents with Mixpanel using xpander.ai. Build intelligent workflows that query event data, analyze user behavior, track funnels, and generate insights from your product analytics.

## About Mixpanel

Mixpanel is a powerful product analytics platform that helps teams understand how users interact with their products through event-based tracking and behavioral analysis.

Key features include:

* **Event Tracking**: Track user actions and interactions in real time, from page views and clicks to custom business events, enabling granular understanding of user behavior.

* **Segmentation**: Slice and dice event data by any property — user attributes, event properties, or time ranges — to uncover patterns and trends across different user segments.

* **Funnels**: Define multi-step conversion funnels to measure drop-off rates, identify bottlenecks, and optimize user journeys from sign-up to activation and beyond.

* **Retention Analysis**: Measure how often users return to your product over time, track engagement curves, and identify what drives long-term user retention.

* **User Profiles**: Maintain rich user profiles with demographic, behavioral, and custom properties, enabling targeted analysis and personalized experiences.

* **Cohort Analysis**: Group users based on shared behaviors or attributes and compare how different cohorts engage with your product over time.

## Authentication Options

Below are possible authentication options you can choose:

<Tabs>
  <Tab title="API Access">
    ### Generate Mixpanel API Credentials

    1. Log in to your [Mixpanel dashboard](https://mixpanel.com).
    2. Navigate to **Settings** → **Project Settings**.
    3. Under **Access Keys**, locate your **API Secret** — copy and store it securely.
    4. Note your **Project ID** from the project settings page (you may need this for certain queries).

    ### Integrate Mixpanel into xpander.ai

    1. In your xpander.ai dashboard, go to the **Connectors** section in the sidebar.
    2. Select **Mixpanel** from the list of available integrations.
    3. Click **Enable**.
    4. Enter a **connector name**, e.g., "xpander-mixpanel".
    5. Choose **Integration User** as the authentication mode.
    6. Select **API Key** as the authentication method.
    7. Set the **Auth Type** to **Custom**.
    8. In the **Custom header name** field, type: `Authorization`
    9. In the **Value** field, enter `Basic` followed by the Base64-encoded value of your API Secret with a trailing colon. For example, if your API Secret is `abc123`, encode `abc123:` in Base64 and enter: `Basic YWJjMTIzOg==`
    10. In the **Interface specific settings** section, set the server URL to: `https://mixpanel.com/api/query`
        * For EU Data Residency: `https://eu.mixpanel.com/api/query`
        * For India Data Residency: `https://in.mixpanel.com/api/query`
    11. Save the configuration.

    <Note>
      To encode your API Secret for Basic auth, run the following command in your terminal:

      ```bash theme={"dark"}
      echo -n "YOUR_API_SECRET:" | base64
      ```

      Then prepend `Basic ` to the output value.
    </Note>
  </Tab>
</Tabs>

## Integration of Mixpanel into AI Agent

Once you've configured your Mixpanel account with the authentication option(s) described above, you can integrate it into your AI agent with xpander.ai:

1. In your xpander.ai dashboard, go to the **Agent Configuration** tab and select **Tools**, then click **Add Tools**.
2. Select **Connectors**.
3. Choose **Mixpanel** with the same **connector name** you configured in the previous section (e.g., xpander-mixpanel).
4. Select the available Mixpanel operations that suit your use case.

### Available Operations

The Mixpanel connector provides the following operations:

**Event Analytics**

| Operation              | Description                                                                  |
| ---------------------- | ---------------------------------------------------------------------------- |
| Get Events Data        | Retrieve event counts over a date range with daily/hourly/weekly granularity |
| Get Common Event Names | List all tracked event names in the project                                  |
| Get Top Events Today   | Show the most popular events with percentage change vs. previous period      |

**Segmentation**

| Operation                       | Description                                                 |
| ------------------------------- | ----------------------------------------------------------- |
| Get Segmented Event Data        | Segment events by any property with date range filtering    |
| Get Average of Event Expression | Calculate the average of a numeric event property over time |
| Get Numeric Segmented Data      | Get numeric breakdowns of event data                        |
| Get Sum of Event Expression     | Calculate the sum of a numeric event property over time     |

**Event Properties**

| Operation                    | Description                                                 |
| ---------------------------- | ----------------------------------------------------------- |
| Get Top Event Property Names | List the most common properties for a given event           |
| Get Top Property Values      | Show the most frequent values for a specific event property |
| Get Event Property Data      | Retrieve detailed property data for events                  |

**Funnels**

| Operation                | Description                                    |
| ------------------------ | ---------------------------------------------- |
| Get Funnel Data          | Retrieve conversion data for a specific funnel |
| Get Funnel Names and IDs | List all configured funnels in the project     |

**User Analytics**

| Operation         | Description                                     |
| ----------------- | ----------------------------------------------- |
| Engage Query      | Query user profiles with filters and pagination |
| Get Activity Feed | Retrieve the activity stream for specific users |
| List Cohorts      | List all defined user cohorts                   |

**Retention**

| Operation                    | Description                                           |
| ---------------------------- | ----------------------------------------------------- |
| Get Retention Data           | Measure user retention over configurable time windows |
| Get Addiction Retention Data | Analyze frequency-based retention patterns            |

**Advanced**

| Operation       | Description                                                                 |
| --------------- | --------------------------------------------------------------------------- |
| Query JQL       | Run custom JQL (JavaScript Query Language) expressions for complex analysis |
| Get Report Data | Retrieve data from saved Insights reports by bookmark ID                    |

## AI Agent Mixpanel Prompt Library

Below are possible prompts or use cases you can try after integrating Mixpanel into your xpander AI agent:

```
What events are being tracked in our Mixpanel project?
```

```
Show me Login event trends from {start_date} to {end_date}.
```

```
Show me Page View events segmented by the page property over the last 2 weeks.
```

```
What are the top events today and how do they compare to yesterday?
```

```
Show me the activity feed for user {distinct_id} from the last 7 days.
```

```
Show me our user profiles — who are our enterprise plan users?
```

```
What are the most common values for the connector_type property of Add Connector events?
```

```
What is the average number of API Call events per day this month?
```

## Related Resources

* [Mixpanel Documentation](https://docs.mixpanel.com)
* [Mixpanel Query API Reference](https://developer.mixpanel.com/reference/query-api)
