Skip to main content
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 UserJourneys 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 UserJourneys interviews client in the same module where you export your Mixpanel instance.
analytics.ts
import { createUserJourneysInterviews } from "@userjourneys/interviews-react-native";

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

export const interviews = createUserJourneysInterviews({
  publicKey: "USERJOURNEYS_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:
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 for the runtime flow, and Study Launch 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.
AppRoot.tsx
import {
  UserJourneysInterviewHost,
} from "@userjourneys/interviews-react-native";
import { interviews } from "./analytics";

export function AppRoot() {
  return (
    <>
      <AppNavigator />
      <UserJourneysInterviewHost client={interviews} />
    </>
  );
}
When UserJourneys 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 UserJourneys web interview in-app.