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

# Mixpanel setup

> Use Mixpanel events and cohorts with the UserJourneys React Native interview SDK.

Use this recipe when Mixpanel is the analytics client your app already imports
and calls from product code. There are two supported paths:

* event-triggered interviews from the app's existing `mixpanel.track(...)`
  calls;
* synced cohort prompts from Mixpanel cohorts imported into UserJourneys.

The interview SDK does not replace Mixpanel. Your app still tracks product
events in Mixpanel, and UserJourneys decides which configured events or synced
cohorts should show an interview prompt.

## Wrap the exported Mixpanel client

Create the interviews client in the same module where you export
your Mixpanel instance.

```ts analytics.ts theme={null}
import { createInterviewClient } from "@userjourneys/interviews-react-native";

const rawMixpanel = new Mixpanel("MIXPANEL_TOKEN", true);

export const interviews = createInterviewClient({
  publicKey: "INTERVIEWS_PUBLIC_KEY",
  referenceId: currentUser.id,
  metadata: {
    app_version: appVersion,
  },
  mapTrackProperties: (_eventName, properties) => ({
    total: typeof properties?.total === "number" ? properties.total : null,
    currency:
      typeof properties?.currency === "string" ? properties.currency : null,
  }),
});

export const mixpanel = interviews.wrapTrackClient(rawMixpanel);
```

Your existing product code keeps using the exported client:

```ts theme={null}
mixpanel.track("Order Completed", {
  total: 50,
  currency: "USD",
});
```

## What UserJourneys receives

For event-triggered launches, UserJourneys receives only:

* the event name;
* the `referenceId` configured on the SDK;
* the primitive metadata returned by `mapTrackProperties`;
* app-level `metadata`, if configured.

Nested Mixpanel payloads, private provider fields, tokens, emails, and raw user
profiles are not forwarded unless you explicitly map them.

## Sync Mixpanel cohorts

For cohort-based prompts, configure Mixpanel to send saved cohort membership to
the UserJourneys Mixpanel cohort sync endpoint. UserJourneys stores active
audience members and Study Launch Rules connect those audiences to studies.

The mobile app does not call Mixpanel cohort APIs and does not carry private
Mixpanel credentials. It only sends the public SDK key and the current
`referenceId` when loading config.

See [Audience prompts](/react-native-interviews/audience-prompts) for the
runtime flow, and [Study Launch Rules](/interviews/targeting-rules) to connect a
synced audience to a study.

## Mount the interview UI

Mount the host once near your app root. It owns the built-in prompt and the
full-screen WebView.

```tsx AppRoot.tsx theme={null}
import {
  InterviewHost,
} from "@userjourneys/interviews-react-native";
import { interviews } from "./analytics";

export function AppRoot() {
  return (
    <>
      <AppNavigator />
      <InterviewHost client={interviews} />
    </>
  );
}
```

When Interview config has an active trigger for a Mixpanel event, the SDK
creates a pending invite and the host shows the native prompt. Starting the
prompt opens the web interview in-app.
