Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Integrate Third-Party Analytics Tools in FlutterFlow

Integrate Mixpanel, Amplitude, or Segment into FlutterFlow using their official Flutter packages added via Custom Code → Pubspec Dependencies. Initialize the SDK once in an App Launch Custom Action, then call track() in individual action flows throughout the app. Segment is the most flexible choice — it routes events to Mixpanel, Amplitude, GA4, and other tools from one integration.

What you'll learn

  • How to add and initialize the Mixpanel, Amplitude, or Segment Flutter SDK in FlutterFlow
  • How to track custom events with properties from action flows and button taps
  • How to identify users and attach user properties for segmentation and cohort analysis
  • How to choose between Mixpanel, Amplitude, and Segment for your specific analytics needs
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner9 min read30-60 minFlutterFlow Free+ (Custom Actions required)March 2026RapidDev Engineering Team
TL;DR

Integrate Mixpanel, Amplitude, or Segment into FlutterFlow using their official Flutter packages added via Custom Code → Pubspec Dependencies. Initialize the SDK once in an App Launch Custom Action, then call track() in individual action flows throughout the app. Segment is the most flexible choice — it routes events to Mixpanel, Amplitude, GA4, and other tools from one integration.

Richer analytics than Google Analytics: funnels, cohorts, and user paths

Google Analytics 4 is great for page views and basic event tracking. But for product analytics — conversion funnels, retention curves, user cohorts, and feature adoption — Mixpanel and Amplitude are purpose-built tools used by the world's top product teams. Segment acts as a routing layer, sending your events to any analytics destination without extra code. This tutorial shows you how to add each SDK to FlutterFlow as a Custom Action, initialize it at app launch, track meaningful events, and identify users for per-user analytics. All three options are implemented via FlutterFlow's Custom Code panel without exporting to Xcode or Android Studio.

Prerequisites

  • FlutterFlow project with Custom Code panel accessible (any paid plan or free plan with custom code)
  • A Mixpanel, Amplitude, or Segment account (all have free tiers)
  • Your analytics project token or API key from the provider's dashboard
  • Firebase Authentication enabled (for user identification with auth.currentUser.uid)

Step-by-step guide

1

Add the analytics SDK to Pubspec Dependencies

Go to Custom Code → Pubspec Dependencies in your FlutterFlow project. Click Add Dependency and add the package for your chosen tool: mixpanel_flutter: ^2.2.0 for Mixpanel, amplitude_flutter: ^3.13.0 for Amplitude, or analytics: ^4.0.1 for Segment. Click Save and then Compile Code to verify the package installs without errors. If you see a version conflict, check the package's pub.dev page for the latest compatible version that supports your Flutter SDK. You can find the Flutter version used by your FlutterFlow project in Settings → Advanced.

Expected result: The analytics package is added and the project compiles without errors.

2

Initialize the SDK in an App Launch Custom Action

Go to Custom Code → Custom Actions and create a new action named initAnalytics. For Mixpanel: import 'package:mixpanel_flutter/mixpanel_flutter.dart'; then implement the async function body as: final mixpanel = await Mixpanel.init('YOUR_PROJECT_TOKEN', optOutTrackingDefault: false); followed by setting the instance in a static variable for access across actions. For Amplitude: AmplitudeFlutter('YOUR_API_KEY'). For Segment: Analytics.setup('YOUR_WRITE_KEY', flushAt: 20). Add this Custom Action to your app's App Launch sequence: go to Settings → App Details → App Launch Actions, click Add Action, and select Call Custom Action → initAnalytics. IMPORTANT: initialize only ONCE here. Do not call init in individual page actions.

analytics_actions.dart
1// Custom Action: initAnalytics (Mixpanel example)
2import 'package:mixpanel_flutter/mixpanel_flutter.dart';
3
4// Global instance (declare at top of file)
5Mixpanel? _mixpanelInstance;
6
7Future<void> initAnalytics() async {
8 _mixpanelInstance = await Mixpanel.init(
9 'YOUR_MIXPANEL_PROJECT_TOKEN',
10 optOutTrackingDefault: false,
11 trackAutomaticEvents: true,
12 );
13 _mixpanelInstance!.setLoggingEnabled(false);
14}
15
16// Separate Custom Action: trackEvent
17Future<void> trackEvent(String eventName,
18 Map<String, dynamic> properties) async {
19 _mixpanelInstance?.track(eventName, properties: properties);
20}
21
22// Separate Custom Action: identifyUser
23Future<void> identifyUser(
24 String userId, String email, String plan) async {
25 _mixpanelInstance?.identify(userId);
26 _mixpanelInstance?.getPeople().set('\$email', email);
27 _mixpanelInstance?.getPeople().set('plan', plan);
28}

Expected result: The analytics SDK initializes at app startup and is ready for event tracking.

3

Identify users after authentication

Create a Custom Action named identifyAnalyticsUser that accepts userId (String), email (String), and plan (String) parameters. For Mixpanel call: mixpanel.identify(userId), then mixpanel.getPeople().set(properties map). For Amplitude: client.setUserId(userId), client.setUserProperties(properties). For Segment: Analytics.identify(userId, traits: {'email': email, 'plan': plan}). Add this Custom Action to the action flow that runs AFTER a successful login or account creation. In the action flow, after Firebase Auth login succeeds, call identifyAnalyticsUser with FFAppState().currentUser.uid, the user's email, and their subscription tier. This ensures all future events are attributed to the correct user in your analytics dashboard.

Expected result: After login, the analytics platform associates all future events with the authenticated user's profile.

4

Track custom events from button taps and action flows

Create a Custom Action named trackAnalyticsEvent that accepts eventName (String) and properties (JSON/Map) parameters. Implement it as a thin wrapper calling the SDK's track method. Now add this action to key moments in your app: button tap → Open Action Flow Editor → Add Action → Call Custom Action → trackAnalyticsEvent. Pass the event name as a string constant (e.g., 'purchase_completed') and properties as a JSON object with relevant context (e.g., {'amount': 49.99, 'product_id': 'pro_monthly', 'currency': 'USD'}). Key events to track in most apps: 'screen_viewed' with page name, 'button_tapped' with button label, 'form_submitted' with form name, 'purchase_completed' with amount, 'feature_used' with feature name.

Expected result: Custom events appear in the Mixpanel/Amplitude/Segment event stream within a few minutes of being triggered.

5

Set up funnels and cohorts in the analytics dashboard

In Mixpanel: go to Funnels → Create Funnel. Add your conversion steps in order: 'app_opened' → 'signup_started' → 'signup_completed' → 'purchase_completed'. Set the funnel window (7 days). Mixpanel shows the drop-off at each step and the profiles of users who dropped. In Amplitude: go to Charts → Funnel Analysis. Add the same events. In Segment, events are forwarded to your configured destinations. Also create a Retention chart: Mixpanel → Retention → select 'signup_completed' as the first event and 'purchase_completed' as the return event → view day-1, day-7, day-30 retention. These charts show which features drive users back.

Expected result: Analytics dashboards show conversion funnels and retention curves built from your tracked events.

Complete working example

analytics_complete.dart
1// Complete analytics setup for FlutterFlow Custom Actions
2// Package: mixpanel_flutter: ^2.2.0
3import 'package:mixpanel_flutter/mixpanel_flutter.dart';
4
5Mixpanel? _mp;
6
7// 1. App Launch Action: initAnalytics()
8Future<void> initAnalytics() async {
9 _mp = await Mixpanel.init(
10 'YOUR_TOKEN_HERE',
11 optOutTrackingDefault: false,
12 trackAutomaticEvents: true,
13 );
14}
15
16// 2. After login: identifyUser(userId, email, plan)
17Future<void> identifyUser(
18 String userId, String email, String plan) async {
19 if (_mp == null) return;
20 _mp!.identify(userId);
21 _mp!.getPeople().set('\$email', email);
22 _mp!.getPeople().set('plan', plan);
23 _mp!.getPeople().set('\$created', DateTime.now().toIso8601String());
24}
25
26// 3. On any button/action: trackEvent(name, props)
27Future<void> trackEvent(
28 String name, Map<String, dynamic> props) async {
29 _mp?.track(name, properties: props);
30}
31
32// 4. On logout: resetUser()
33Future<void> resetUser() async {
34 _mp?.reset();
35}

Common mistakes

Why it's a problem: Initializing the analytics SDK on every page load instead of once at App Launch

How to avoid: Add the init Custom Action to Settings → App Details → App Launch Actions and never call it again. Use a static or global Dart variable to hold the single SDK instance and reference it from all tracking actions.

Why it's a problem: Using generic event names like 'button_tapped' for all buttons

How to avoid: Use specific, descriptive event names following the noun-verb convention: 'signup_button_tapped', 'purchase_completed', 'profile_updated'. Include the screen or context as an event property.

Why it's a problem: Sending personally identifiable information (PII) in event properties to Mixpanel or Amplitude

How to avoid: Use anonymous identifiers (Firebase UID, not email) in event properties. Set email and name as user profile properties via identify() where the platform applies appropriate data handling. Never include payment card details, SSNs, or passwords in any analytics event.

Best practices

  • Use Segment as your analytics router if you expect to switch between or use multiple analytics tools — one integration, unlimited destinations
  • Define an event taxonomy document before implementing tracking: list every event name, its trigger, and required properties to ensure consistency across your team
  • Track the minimum viable events first (signup, purchase, key feature use) and expand as you learn what questions you need to answer
  • Always call identify() with the same userId you use in Firebase Auth so you can join analytics data with your Firestore user records
  • Flush analytics events before app background using AppLifecycleState.paused — some SDKs batch events and may lose them if the app is killed before flushing
  • Use Super Properties (Mixpanel) or User Properties (Amplitude) for dimensions that apply to every event, like subscription tier and app version
  • Set up a test environment property in all events ('environment': 'development' vs 'production') so you can filter test events from your dashboards

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am integrating Mixpanel analytics into a FlutterFlow app using the mixpanel_flutter Dart package. Write me three Custom Action functions: (1) initMixpanel(String projectToken) that initializes the SDK, (2) trackEvent(String eventName, Map<String, dynamic> properties) that tracks a custom event, and (3) identifyUser(String userId, String email, String plan) that identifies the user and sets their profile properties. Use a global Dart variable to hold the Mixpanel instance across calls.

FlutterFlow Prompt

Add analytics tracking to my FlutterFlow signup flow. When the user submits the signup form successfully, call my trackEvent Custom Action with event name 'signup_completed' and properties: {method: 'email', source: the UTM source from App State, has_referral: whether a referral code was entered}. Then call identifyUser with the new user's Firebase UID, email, and 'free' as the initial plan.

Frequently asked questions

Which analytics tool should I use — Mixpanel, Amplitude, or Segment?

For a new app: use Segment as your starting point. Segment's free tier routes events to Mixpanel, Amplitude, Google Analytics, and others simultaneously. You can switch or add destinations without changing your FlutterFlow code. If you want a standalone tool: Mixpanel excels at funnel analysis and cohorts with a generous free tier (20M monthly events). Amplitude is strong for behavioral analytics and has a similar free tier. Both are significantly better than GA4 for product analytics.

How do I track screen views automatically in FlutterFlow?

FlutterFlow generates navigation code automatically, but you need to hook analytics tracking into each page's On Page Load action. Create a trackScreen Custom Action and add it as the first action in every page's On Page Load flow, passing the page name as a parameter. Some SDK packages (mixpanel_flutter with trackAutomaticEvents: true) auto-track some screen events, but explicit tracking gives you cleaner, more reliable data.

Can I track analytics without showing users a consent banner?

In the EU and UK, analytics that collect personal data or use identifiers tied to a person require GDPR consent before tracking. In the US, CCPA applies for California residents. Best practice: show a consent prompt on first launch, default to opted-out, and only initialize and identify() after consent. The mixpanel_flutter SDK has optOutTrackingDefault: true to start opted out until consent is given.

Will analytics tracking slow down my FlutterFlow app?

No. Analytics SDKs batch events in memory and flush them in the background (typically every 10 events or 30 seconds). The track() call itself is non-blocking and returns immediately. The negligible memory usage (a few KB for the event queue) and background network call have no perceptible impact on app performance.

How do I test that analytics events are being sent correctly?

Mixpanel: enable Live View in your project dashboard — events appear in real-time as you test. Amplitude: use the Event Explorer in the dashboard. For any SDK, add temporary logging in your Custom Action: print('Analytics: $eventName $properties') and check the FlutterFlow Run mode console. For Segment, the debugger panel shows all events and their delivery status to each destination.

What if I need help setting up analytics tracking across a complex FlutterFlow app?

Implementing consistent analytics tracking across a full app — covering all key flows, user journeys, and conversion events — requires systematic planning. RapidDev can audit your existing FlutterFlow app and implement a complete analytics taxonomy covering every screen, action, and user segment relevant to your business goals.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.