Apps
Flutter
Analytics for Flutter apps and games on Android, iOS, macOS, Windows, Linux and web. Only dependency — the http package.
In progress: The Flutter SDK is feature-complete but still being tested on real devices. Feel free to try it — for production we currently recommend the web script, Android and JavaScript.
Overview
- No device identifiers, no advertising ids, no device model, no fingerprinting.
- Nothing is written to the device (no shared_preferences, no files). Events and the session id live in memory only.
- Batched delivery with automatic retry and a neutral
User-Agent: trackd-flutter/<version>.
Requirements: Flutter 3.10+ (Dart 3.0+).
Install
The pub.dev package is coming. Until then:
- Download
trackd.dartand put it atlib/trackd.dart. - Add the only dependency:
flutter pub add http. - Import it relatively:
import 'trackd.dart';.
# pubspec.yaml — trackd.dart only needs the http package
dependencies:
http: ^1.2.0
Platform setup — do not skip
Android: release builds need the internet permission in android/app/src/main/AndroidManifest.xml — Flutter only adds it to the debug and profile manifests:
<uses-permission android:name="android.permission.INTERNET" />
macOS: add the entitlement to macos/Runner/DebugProfile.entitlements and Release.entitlements:
<key>com.apple.security.network.client</key>
<true/>
iOS, Windows, Linux: nothing to do. Web: requests carry an Origin header — the app must be served from the registered domain.
Setup
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'trackd.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
Trackd.init(
websiteId: 'YOUR_WEBSITE_ID',
appVersion: '1.2.0', // e.g. from package_info_plus
debug: kDebugMode,
);
runApp(MaterialApp(
navigatorObservers: [TrackdNavigatorObserver()], // screen tracking for named routes
routes: {'/': (_) => const HomePage(), '/settings': (_) => const SettingsPage()},
));
}
platform, screen, language and device are detected from the Flutter engine, osVersion on iOS, iPadOS, macOS and Windows via Platform.operatingSystemVersion. You can override every value in init.
On Android, Linux and web Flutter provides no OS version without an extra package. If you want to see it, pass it yourself, e.g. with device_info_plus:
final android = await DeviceInfoPlugin().androidInfo;
Trackd.init(websiteId: 'YOUR_WEBSITE_ID', osVersion: 'Android ${android.version.release}');
Without osVersion the dashboard still shows the operating system (e.g. “Android”), just without a version number.
Track purchases & revenue
Send revenue right after a successful purchase — with in_app_purchase in the purchaseStream, when the status is PurchaseStatus.purchased:
InAppPurchase.instance.purchaseStream.listen((purchases) async {
for (final p in purchases) {
if (p.status == PurchaseStatus.purchased) {
final product = products[p.productID]!; // ProductDetails from queryProductDetails()
Trackd.revenue(product.rawPrice, currency: product.currencyCode, orderId: p.purchaseID);
}
if (p.pendingCompletePurchase) await InAppPurchase.instance.completePurchase(p);
}
});
Don’t send PurchaseStatus.restored — a purchase would count twice. The event is called purchase and carries { amount, currency, order_id }. It shows up under Revenue and can be a funnel step: a Paywall → purchase funnel (screen view /paywall → event purchase) shows how many sessions with a paywall actually buy. The Analytics page calculates this conversion automatically once it detects a paywall screen, and Funnels has a template for it. Currencies and edge cases: Revenue tracking.
API
Trackd.screen('Home'); // screen view (alias: screenView)
Trackd.screen('Settings/Profile', title: 'Profile');
Trackd.event('signup', {'plan': 'pro', 'trial': true});
Trackd.revenue(4.99, currency: 'EUR', orderId: 'order-123'); // → event "purchase"
await Trackd.flush();
Trackd.setEnabled(false); // opt-out: stop + clear the queue
// Game & media helpers
Trackd.gameStart(level: 1, mode: 'hard');
Trackd.levelComplete(5, score: 1200, timeMs: 45000);
Trackd.gameOver(3, reason: 'fell');
Trackd.videoWatch('intro', durationMs: 30000, completed: true);
Trackd.adView('rewarded', adId: 'ad-1');
Trackd.tutorialStep(2, 5, skipped: false);
Event data must be flat (String, num, bool); the JSON is limited to 4 KB.
Screen tracking
TrackdNavigatorObserver tracks every named route on push, replace and pop (dialogs and bottom sheets are ignored). Map routes with parameters to generic names — never send user data:
TrackdNavigatorObserver(
nameExtractor: (settings) => settings.name?.replaceAll(RegExp(r'/\d+'), '/:id'),
)
go_router: GoRouter(observers: [TrackdNavigatorObserver()], …) and give your GoRoutes a name. Without named routes, track manually in initState with Trackd.screen('Checkout').
Store privacy forms
Google Play: App activity → App interactions (+ Other actions with revenue) + Location → Approximate location, analytics, not shared, no device IDs. App Store: Product Interaction (+ Purchase History with revenue) + Coarse Location, not linked, no tracking (merge the entries into your iOS app’s PrivacyInfo.xcprivacy).
Lifecycle, batching, sessions
- A
WidgetsBindingObserverflushes the queue when the app is paused/hidden and starts a new session after 30 minutes in the background or 30 minutes without events (measured withStopwatchand the wall clock — whichever shows more, so device standby counts too). - Events tracked before
initstay in memory and are then sent with the configuredflushInterval/flushAt. - Flush at 20 events, 30 s after an event and on
flush(); max. 50 events / 60 KB per request, max. 500 queued. - Network errors,
5xx,408,429→ exponential backoff (1 s … 5 min); the same batch is resent with the samebatch_id.
Ready in minutes
Start the 7-day free trial (no credit card), add your website or app, copy the snippet.