Flutter Product Analytics installation

Install with the wizard

Run this command in your project directory to add PostHog to your Flutter project. The wizard detects your framework, installs the SDK, and sets up your first events.

Learn more

Or set it up manually by following the rest of this guide.

CocoaPods is becoming read-only. CocoaPods trunk becomes read-only on December 2, 2026, and posthog-ios 4.0 and later is only published through Swift Package Manager (SPM).

posthog_flutter 6.0 and later uses posthog-ios 4.0 and installs on iOS and macOS through SPM only. It has no podspec. It needs Xcode 26 or later, iOS 15, and macOS 11. Flutter 3.44 and later turn SPM on by default. See the Flutter migration guide.

posthog_flutter 5.x stays on posthog-ios 3.x through CocoaPods or SPM. If your app can't use SPM, stay on 5.x. That includes a Flutter module embedded in an iOS app on Flutter earlier than 3.50, which installs module plugins with CocoaPods.

posthog_flutter 6.0 also needs Flutter 3.41 or later on every platform, including Android and web. flutter pub get fails on an older Flutter.

  1. Install the package

    Required

    Add the PostHog Flutter SDK to your pubspec.yaml:

    pubspec.yaml
    posthog_flutter: ^5.24.0
  2. Platform setup

    Required

    Add these values to your AndroidManifest.xml:

    android/app/src/main/AndroidManifest.xml
    <application>
    <activity>
    [...]
    </activity>
    <meta-data android:name="com.posthog.posthog.PROJECT_TOKEN" android:value="<ph_project_token>" />
    <meta-data android:name="com.posthog.posthog.POSTHOG_HOST" android:value="https://us.i.posthog.com" />
    <meta-data android:name="com.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTS" android:value="true" />
    <meta-data android:name="com.posthog.posthog.DEBUG" android:value="true" />
    </application>

    Update the minimum Android SDK version to 21 in android/app/build.gradle:

    android/app/build.gradle
    defaultConfig {
    minSdkVersion 23
    // rest of your config
    }
  3. Send events

    Recommended

    Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration:

    Dart
    import 'package:posthog_flutter/posthog_flutter.dart';
    await Posthog().capture(
    eventName: 'button_clicked',
    properties: {
    'button_name': 'signup'
    }
    );
  4. Next steps

    Recommended

    Now that you're capturing events, continue with the resources below to learn what else Product Analytics enables within the PostHog platform.

    ResourceDescription
    Capturing eventsLearn how to capture custom events beyond autocapture
    Identifying usersAssociate events with specific users
    Creating insightsBuild trends, funnels, and retention charts
    Group analyticsTrack events at the company or account level

Still have questions?

Was this page useful?