Introduction
The Nemu Flutter SDK (nemu_tracking_flutter) allows you to integrate Nemu’s attribution and Smart Links system directly into your Flutter application.
With the SDK you can:
- Capture the install source — know which campaign, source, or media the user came from (UTMs)
- Process direct deep links — when the user clicks a Smart Link and the app is already installed
- Process deferred deep links — when the user clicks a Smart Link, installs the app from the store, and opens it for the first time
- Identify users — associate an ID from your system with the device to cross-reference attribution data
- Query session history — retrieve the UTMs from the user’s last interaction
Prerequisites
| Requirement | Minimum version |
|---|---|
| Flutter | >= 3.10.0 |
| Dart SDK | >= 3.0.0 < 4.0.0 |
| iOS | 12.0+ |
| Android | API 21+ (Android 5.0) |
Installation
1. Access token configuration
Thenemu_tracking_flutter package is private and hosted in a restricted-access Git repository. Before installing, you need to configure authentication.
Get your access
Contact the Nemu support team to receive access to the SDK repository:- Email: suporte@usenemu.com
- Website: nemu.com.br
2. Package installation
Add the SDK to yourpubspec.yaml file:
Via Git repository (recommended)
Via local path (for development)
All required dependencies (
shared_preferences, flutter_secure_storage, app_links, etc.) are automatically installed as transitive dependencies of the SDK. You don’t need to add them manually to your project.Native configuration
iOS
1. Configure Universal Links (required for direct deep links)
For iOS to forward Smart Links directly to the app (without opening the browser), you need to configure Associated Domains. In Xcode:- Open the
.xcworkspaceproject (atios/Runner.xcworkspace) - Select the Runner target
- Go to Signing & Capabilities
- Click + Capability and add Associated Domains
- Add the domain in the format:
The exact domain will be provided by the Nemu team along with the credentials.
2. Configure the URI Scheme (required)
In theios/Runner/Info.plist file, add your app’s URI scheme:
yourapp with the scheme defined in the Nemu dashboard for your Smart Link.
The URI scheme configured here must match the value passed in the
uriScheme parameter during SDK initialization.Android
1. Configure Deep Links in AndroidManifest.xml
For Smart Links to open the app directly, add intent filters to your mainActivity.
In the android/app/src/main/AndroidManifest.xml file, inside the main <activity> tag (the one containing android:name=".MainActivity"):
App Links (Android Universal Links):
your-domain.nemu.com.br and yourapp with the values corresponding to your project.
2. Internet permission (usually already present)
Check thatAndroidManifest.xml has the internet permission:
In most Flutter projects, this permission is already included by default.
Initialization
SDK initialization should be done only once, as early as possible in the app lifecycle — ideally in theinitState of your root widget or in the main function.
Configuration parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | String | Yes | API key obtained from the Nemu dashboard |
uriScheme | String | Yes | App URI scheme (e.g.: "yourapp"). Must match the value configured in the Smart Link |
trackingId | String | Yes | Tracking ID associated with the app in the Nemu dashboard |
isDebugMode | bool | No | Enables detailed logs in the console. Default: false |
baseUrl | String? | No | Overrides the API base URL (only when isDebugMode is true) |
Full initialization example
Using environment variables
To avoid exposing credentials directly in your code, use theflutter_dotenv package or define variables via --dart-define:
Using --dart-define (recommended)
Using flutter_dotenv
Create a .env file at the project root:
User identification
After the user logs into your app, associate their ID with the device. This allows Nemu to cross-reference attribution data with your user system.Register user
Clear user on logout
clearUserId() only removes the local association. The attribution history on the backend is preserved.Deep Links
The SDK automatically processes two types of deep links:Direct deep links
Occur when the app is already installed and the user clicks a Smart Link. The operating system opens the app directly (via Universal Link / App Link or URI scheme). The flow is transparent:- The user clicks the Smart Link
- The app opens with the URL
- The SDK processes the URL and registers the session
- Listeners registered via
onDeepLinkare notified with the data
Deferred deep links (Deferred Deep Links)
Occur when the app is not installed. The user clicks the Smart Link, is redirected to the store, installs the app, and opens it for the first time. The SDK automatically detects this scenario on the first launch and delivers the attribution and deep link data viaonDeepLink with isDeferred: true.
Reactive listener (onDeepLink)
Register a callback to receive deep link data as soon as it becomes available:Automatic replay: if a deep link was already processed before the listener was registered, the callback is fired immediately with the most recent data. This prevents the app from missing the initial deep link.
Imperative query (getDeepLinkData)
If you prefer to query the data imperatively instead of using the listener:DeepLinkData structure
Session history
Last session history (last touch)
Query the UTMs from the user’s most recent interaction. Answers the question: “what were the UTMs from the last visit?”Example: attaching UTMs to a purchase
Advanced usage
Debug mode
Enable debug mode to see detailed logs of all SDK operations in the console:[NemuSDK] and include information about:
- Deep link processing
- Initialization flow
- Network errors and failures
Base URL override
In development or staging environments, you can point the SDK to a different API:The
baseUrl is only used when isDebugMode is true. In production mode, the SDK always uses the default URL.Exported types
The SDK exports the following Dart types for use in your application:NemuInitParams
DeepLinkData
UtmData
SessionHistory
SessionInfo
DeepLinkCallback
Troubleshooting
”flutter pub get” fails to resolve the package
Error:- Check that you have access to the SDK Git repository
- Confirm that your Git credentials (SSH or HTTPS) are properly configured
- Contact Nemu support to validate your access
Initialization error: “NemuTracking must be initialized before use”
Cause: an SDK method was called before initialization. Solution: make sureNemuTracking.instance.init() is called in the root widget’s initState before any other SDK method.
Deep links not working on iOS
Checks:- Is the Associated Domain correctly configured in Xcode? (format:
applinks:your-domain) - Is the
apple-app-site-associationfile published and accessible on the domain? (configured by the Nemu team) - Is the URI scheme declared in
Info.plist? - Is
WidgetsFlutterBinding.ensureInitialized()being called beforerunApp?
Deep links not working on Android
Checks:- Are the intent filters correct in
AndroidManifest.xml? - Is the domain with automatic verification active (
android:autoVerify="true")? - Is the
assetlinks.jsonfile published on the domain? (configured by the Nemu team) - Is
MainActivityconfigured withlaunchMode="singleTop"orsingleTask?
No attribution data returned
Checks:- Are the
apiKeyandtrackingIdcorrect? - Is the Smart Link configured and active in the Nemu dashboard?
- Test with
isDebugMode: trueand check the[NemuSDK]logs in the console
flutter_secure_storage fails on Android
Error:- Check that
minSdkVersioninandroid/app/build.gradleis at least 21 - On devices with Android < 6.0, you may need to configure
flutter_secure_storagewith specific options. See the package documentation
Need help? Contact the Nemu support team:
- Email: suporte@usenemu.com
- Website: nemu.com.br