Flutter web 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.
Or set it up manually by following the rest of this guide.
- 1
Install the package
RequiredAdd the PostHog Flutter SDK to your
pubspec.yaml:pubspec.yamlposthog_flutter 6.0requires Flutter 3.41 or later on every platform.If you embed Flutter in an iOS app as a module (
flutter create -t module), use Flutter 3.50 or later and build it withflutter build swift-package. Earlier Flutter versions install module plugins with CocoaPods, andposthog_flutter6.0 has no podspec, so stay onposthog_flutter5.x there. - 2
Platform setup
RequiredAdd these values to your
AndroidManifest.xml:android/app/src/main/AndroidManifest.xmlposthog_flutter needs a minimum Android SDK version of 23 or higher. New Flutter projects default to 24, so change
android/app/build.gradleonly if your app sets a lower value:android/app/build.gradleAdd these values to your
Info.plist:ios/Runner/Info.plistiOS and macOS builds require Xcode 26 or later. Set the minimum deployment target to iOS 15.0, or macOS 12.0 for a macOS app, in Xcode (Runner > General > Minimum Deployments). PostHog installs through Swift Package Manager, which is on by default from Flutter 3.44. On Flutter 3.41 to 3.43, or if you turned it off, run
flutter config --enable-swift-package-manager. If you keep aPodfilefor other plugins, setplatform :ios, '15.0'there too (platform :osx, '12.0'inmacos/Podfile), then runflutter build ios --config-only(orflutter build macos --config-only).Add these values in
index.html:web/index.html - 3
Track screen views
RecommendedDespite the name, the web analytics dashboard can be used to track screen views in mobile apps, too. Open your app and view some screens to generate some events.
To automatically capture screen views, you can use the
PostHogObserverwith your navigation:Dart - 4
Next steps
RecommendedAfter installing PostHog and ensuring autocapture is enabled, head to your web analytics dashboard to see your data. And then check out our start here guide.
PostHog tip: Web analytics works with anonymous events. This means if you are primarily using PostHog for web analytics, it can be significantly cheaper for you.





