Skip to main content
Connect your Mixpanel project to export router exposure data for analysis and import your product events to define custom metrics in Portal.

Prerequisites

1

Find your Mixpanel Project ID

In Mixpanel, navigate to Settings > Project Settings. In the Overview tab, find and copy your Project ID.
2

Create a service account

In Project Settings, go to the Service Accounts tab. Click Add Service Account.Type in the name of your new service account. Click the + button to create your new service account. Set the Project Role to Admin or Owner. Set Expires to Never.Click Add and copy the username and secret — you will not be able to view the secret again.
3

Configure the integration in Portal

In Portal, go to Routers and click Set Up Metrics to open the Data Integrations page, then click Add Integration and select Mixpanel. Enter the following:
FieldValue
Project IDYour Mixpanel project ID from Step 1
Service Account UsernameThe service account username from Step 2
Service Account SecretThe service account secret from Step 2
Click Enable to save your credentials. You can then toggle export and import independently in the Data Sync section.

Exporting to Mixpanel

Toggle Export to Mixpanel on in the Data Sync section of your integration settings. When enabled, router exposure data is automatically sent to your Mixpanel project.

Make a request to your router

Call the Chat Completions API with your router, populating the Mixpanel Distinct ID that corresponds to the user in the user field:
curl --request POST \
  --url https://api.inworld.ai/v1/chat/completions \
  --header 'Authorization: Basic <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "inworld/my-router",
    "messages": [{"role": "user", "content": "Hello"}],
    "user": "<mixpanel-distinct-id>"
  }'
The router exposure data will match the user to the Mixpanel Distinct ID when creating events in Mixpanel, so you can tie the specific request to the right user.

View events in Mixpanel

The router exposure data will flow to your Mixpanel project automatically (data syncs every ~8 hours). You will see an event for each router, route, and variant that a user was exposed to every hour. Each event will include:
  • alias_id — Your router’s ID
  • route_id — The route that the user was routed to
  • variant_id — The variant that the user was exposed to
  • Time — The time of the most recent event in the hourly bucket in which the user was exposed to this router, route, and variant
The Distinct ID of the event will be what was passed in the user field of the request.

Analyze your data

We recommend creating a Borrowed Event Property. To do so, create a Custom Event Property and select Computed > Borrow Property. Select the Inworld Router Exposure event and alias_id, route_id, or variant_id based on what property you want to analyze your data by. borrow-event.gif Now you can use the property in any Breakdown of a report to see how your metrics trend based on the router, route, or variant that the user was exposed to.

Importing from Mixpanel

Toggle Import from Mixpanel on in the Data Sync section to start pulling your product events into Portal.

Define events to import

In the Events to import section that appears after enabling import, click Add Event and configure:
FieldDescriptionExample
Event IDThe Mixpanel event name to import. Must exactly match the event name in your Mixpanel project.purchase
DescriptionOptional description of when this event is emitted.Fires when a user completes a purchase
Event IDs can only contain letters, numbers, underscores, and hyphens.
You can add multiple events — each one will be imported separately and will be available as a distinct event when creating custom metrics.

How import works

  • Inworld uses the same service account credentials configured in Prerequisites to read events from your Mixpanel project.
  • Events are synced approximately every 8 hours.
  • User identity is matched using the Mixpanel Distinct ID. To correlate imported events with router exposures, ensure the same user identifier is passed as the user field in your Chat Completions API requests and as the Distinct ID in your Mixpanel events.
  • Once events are imported, their properties are automatically discovered and become available for metric configuration.

Next steps

Once your events are importing, create custom metrics to track how routing decisions impact your KPIs.