More in App analytics
- What is the crash-free rate and where do I see it?
- How do I track app versions?
- How do I install the Android SDK?
- How do I install the iOS SDK?
- How do I track screen views in my app?
- How do I add TapCub to a React Native app?
- How do I add TapCub to a HarmonyOS app?
- How do I check daily, weekly and monthly active users of my app?
- All guides in this category
Still have a question?
Could not find it? A person reads every message, usually within a few hours on business days.
Chat with usShort answer
Register both your Android applicationId and iOS bundle ID under App analytics › Configuration › SDK code, run flutter pub add tapcub_flutter, call TapCub.preInit and TapCub.init at startup, and add TapCub.navigatorObserver to MaterialApp so named routes are sent as screens. The plugin forwards every call to the native Android and iOS SDKs, so launches, sessions and crashes are collected by them.
Requirements
tapcub_flutter0.2.0 needs Flutter 3.44 and Dart 3.12 or newer. On older Flutter, usetapcub_flutter: ^0.1.0.- iOS uses Swift Package Manager by default; the plugin fetches
tapcub-iosautomatically. - Android depends on
com.tapcub:android(0.1.1 or later) from Maven Central, with no extra setup.
1. Register both app identifiers
Open App analytics › Configuration › SDK code and click Add app identifier twice: once for the Android applicationId and once for the iOS bundle ID. Data from an identifier that is not registered is dropped silently.
2. Install
flutter pub add tapcub_flutter
If your iOS project has Swift Package Manager turned off and uses CocoaPods, add this inside target 'Runner' do in ios/Podfile, then run pod install:
pod 'TapCub', :git => 'https://github.com/tapcub/tapcub-ios.git', :tag => '0.1.0'
3. Initialize
import 'package:tapcub_flutter/tapcub_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await TapCub.preInit(TapCubConfig(
siteKey: 'YOUR_SITE_KEY',
appId: 'com.example.app',
));
// after the user accepts the privacy policy:
await TapCub.init();
runApp(const MyApp());
}
appId must match the identifier registered for the native app. For China mode, pass region: 'cn', call init after consent and then TapCub.grantConsent(['analytics']).
The native SDKs record launches and foreground/background on their own. On Android the plugin hands the current Activity to the native SDK so the cold start is reported too.
4. Track screens
MaterialApp(
navigatorObservers: [TapCub.navigatorObserver],
// ...
);
On push, replace and pop the observer reads the route's settings.name and sends a screen view. Unnamed routes are skipped, and the same name as last time is not sent again. Give routes names (RouteSettings(name: 'Checkout') or named routes), or call TapCub.trackScreen('Home') yourself.
5. Events and identity
await TapCub.track('purchase', {'revenue': 19.9, 'currency': 'USD'});
await TapCub.login('USER_ID'); // type defaults to 'login'
await TapCub.login('a@example.com', type: 'email');
await TapCub.logout();
In this version setProps is stored as event super properties. Call TapCub.flush() to ask the native SDK to send queued events now.
6. Verify
Run on an Android emulator and an iOS simulator and open App analytics › Overview › Realtime. Start events should arrive from both platforms within seconds; use the platform filter in the header to separate them.
Troubleshooting
PlatformExceptionon the first call: the native library is missing from the build. Run a full rebuild (flutter clean, then build again); on CocoaPods projects check the Podfile line.- No data from one platform: that platform's identifier is not registered.
- No screens: the observer is not on
MaterialApp, or routes have nosettings.name. - Queue and retries follow the native SDKs (SQLite on Android, files on iOS).
Related
Did this answer your question?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.