Table of Contents
Introduction Quick Start Guide I want to know more!
Introduction
Welcome to the official Mixpanel Flutter SDK. The Mixpanel Flutter SDK is an open-source project, and we’d love to see your contributions! We’d also love for you to come and work with us! Check out Jobs for details
Quick Start Guide
Check out our official documentation for more in depth information on installing and using Mixpanel on Flutter.
Installation
Prerequisite
Steps
Depend on it Add this to your package’s pubspec.yaml file:
dependencies:
mixpanel_flutter: ^1.0.0 # set this to your desired version
Install it You can install packages from the command line:
$ flutter pub get
Import it Now in your Dart code, you can use:
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
Integration
Initialization
To start tracking with the SDK you must first initialize with your project token. To initialize the SDK, first add import 'package:mixpanel_flutter/mixpanel_flutter.dart'; and call Mixpanel.init(token); with your project token as it’s argument.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
...
class _YourClassState extends State<YourClass> {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future<void> initMixpanel() async {
mixpanel = await Mixpanel.init("Your Mixpanel Token", optOutTrackingDefault: false);
}
...
Once you’ve called this method once, you can access mixpanel throughout the rest of your application.
Tracking
Once you’ve initialized the SDK, Mixpanel will automatically collect common mobile events . You can enable/disable automatic collection through your project settings. With the mixpanel object created in the last step a call to track is all you need to send additional events to Mixpanel.
// Track with event-name
mixpanel.track('Sent Message');
// Track with event-name and property
mixpanel.track('Plan Selected', properties: {'Plan': 'Premium'});
You’re done! You’ve successfully integrated the Mixpanel Flutter SDK into your app. To stay up to speed on important SDK releases and updates, star or watch our repository on Github .
I want to know more!
No worries, here are some links that you will find useful:
Have any questions? Reach out to Mixpanel Support to speak to someone smart, quickly.
Download Flutter Tracking Library source code on GitHub
Official Flutter Tracking Library for Mixpanel Analytics https://github.com/mixpanel/mixpanel-flutter 114 forks. 83 stars. 63 open issues. Recent commits: chore: recommend Swift Package Manager and deprecate CocoaPods in the package READMEs (#310)* docs: recommend Swift Package Manager and deprecate CocoaPods in the package READMEsAdd an iOS and macOS section to the mixpanel_flutter and mixpanel_flutter_session_replay READMEs: Swift Package Manager is recommended (on by default from Flutter 3.44), and CocoaPods is deprecated with the removal note (after November 2027, minimum Flutter 3.44).Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* chore: CocoaPods is the fallback only when Swift Package Manager is offSwift Package Manager can be turned on below Flutter 3.44 with flutter config –enable-swift-package-manager, so describe CocoaPods as the fallback when SPM is turned off rather than the path for older Flutter versions.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>———Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> , GitHub release: prepare common 1.1.0 (#307)Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> , GitHub feat(common): add MixpanelIdentity (#306)* feat(common): add MixpanelIdentityAdd MixpanelIdentity to mixpanel_flutter_common: the user, company anddevice an event, profile update or replay belongs to. It is shared so theidentity mixpanel_flutter reports can be passed to Session Replay as is,and is released ahead of hierarchical groups support so both packages candepend on the published package.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* refactor(common): mark the MixpanelIdentity device id constructors internalCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>———Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> , GitHub fix(analytics): stop duplicate Android method-channel replies (SDK-280) (#304)* fix(analytics): stop duplicate Android method-channel replies (SDK-280)setFlushBatchSize was missing a break, so it fell through into identify:identify(null) ran (rejected by the native SDK) and result.success() wascalled a second time, throwing "IllegalStateException: Reply alreadysubmitted" on every setFlushBatchSize call.Also remove a result.success() that followed result.error() ingetSuperProperties' JSONException path, which would throw the same way.Fixes #151Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* test(analytics): add Android regression tests for duplicate repliesAdd JVM unit tests (JUnit + Mockito) for the Android plugin covering bothdouble-reply paths fixed in the previous commit:- setFlushBatchSize replies once and never calls identify- getSuperProperties replies only with an error when conversion failsBoth tests fail against the pre-fix sources (NeverWantedButInvoked) andpass with the fix. Run them in CI after the example APK build.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* test(analytics): replace Mockito with fakes and MockK in plugin testsPer review, drop Mockito. Result and the unconvertible JSONObject are nowplain hand-written fakes, and replies are asserted by value. MixpanelAPIis the one collaborator still mocked (with MockK), because itspackage-private constructors need a live Context, SharedPreferences andSQLite and can't run on the JVM.The tests are now in Kotlin, under src/test/kotlin. Both still fail on thepre-fix sources ([success, success] and [error, success]) and pass with thefix.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* test(analytics): remove plugin unit tests from this fixAdding a JVM test framework to the Android plugin is out of scope forthis fix. Remove the regression tests, their test dependencies and the CIstep, so the PR contains only the two-line fix in MixpanelFlutterPlugin.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>———Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> , GitHub release: prepare analytics 3.2.0 (#302)* release: prepare analytics 3.2.0* Promote autocapture to general availabilityAutocapture feature is now generally available, including tracking for clicks, rage clicks, and dead clicks.———Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>Co-authored-by: Rahul Raveendran V P <rahul.raveendran@mixpanel.com> , GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.