How to add Mixpanel to your iOS app
What Mixpanel does for an iOS app
Mixpanel turns raw user actions into product insight. You send events such as signup_completed, trial_started, or note_created, attach properties, and then build funnels to see where users drop off, retention curves to see who comes back, and cohorts to compare segments. After a user signs in you call identify so their events attach to a stable profile across sessions and devices. The SDK sends data using a project token, which is safe to ship because it can write events but cannot read your reports.
Adding Mixpanel with AppFlight
AppFlight's built-in analytics connector is PostHog, so Mixpanel is added the way any external SDK is: you ask the AI to add the Mixpanel Swift package, initialize it with your project token, and track the events you care about. The project token is a client value that ships in the app. Any service account secret for the export or admin API stays server-side, never in the binary. From there the AI can wire your key events and the identify call into the right SwiftUI views.
A SwiftUI example
Initialize Mixpanel at launch, then track an event:
import Mixpanel
import SwiftUI
@main
struct MyApp: App {
init() {
Mixpanel.initialize(token: "YourProjectToken", trackAutomaticEvents: false)
}
var body: some Scene {
WindowGroup { ContentView() }
}
}
struct TrialView: View {
var body: some View {
Button("Start free trial") {
Mixpanel.mainInstance().track(
event: "trial_started",
properties: ["plan": "pro"]
)
}
}
}
Alternatives
PostHog covers the same analytics ground and adds feature flags, experiments, and self-hosting, which makes it AppFlight's default analytics connector. Firebase Analytics is free and integrates with the Google stack, though it is less flexible for ad hoc event analysis. Mixpanel is the choice when you want a refined, analytics-first reporting experience and strong cohort tooling without needing the extra surface area of an all-in-one platform.
FAQ
Is the Mixpanel project token a secret?
No. The project token used by the iOS SDK is a client identifier that is safe to ship in the binary. It can send events but not read your reports. Service account credentials for the export and admin APIs are the secrets and stay server-side.
Mixpanel or PostHog?
Both do event analytics, funnels, and retention well. Mixpanel has a polished reporting interface and strong cohort tooling. PostHog adds feature flags, experiments, and self-hosting in the same product. Pick by whether you want pure analytics polish or an all-in-one open-source stack.
Does Mixpanel track users automatically?
The SDK can capture some lifecycle events, but the value comes from the custom events you define, like trial_started or note_created. You identify a user after sign in so events tie to a profile across sessions and devices.