Overview
The Nemu React Native SDK allows mobile applications developed in React Native to:- Capture UTMs received via deep links
- Persist the user’s session origin
- Associate a logged-in user’s UID with the session
- Retrieve UTMs from the last session for event sending (e.g., sales)
Requirements
- React Native: 0.68 or higher
- Node.js: 16 LTS
Android
- minSdkVersion: 21 (Android 5.0)
- targetSdkVersion: 34 (Android 14)
iOS
- Deployment Target: 11.0+
android/ and ios/ folders.
Installation
1. Install the SDK
2. iOS Installation
3. Android Installation
Add the dependency below inandroid/app/build.gradle:
Credentials Configuration
To initialize the SDK, you will need:- Nemu PIXEL_ID
- Nemu SDK_TOKEN
To obtain the PIXEL_ID and SDK_TOKEN, talk to your Nemu account manager.
Using environment variables (react-native-config)
- Install the dependency:
- Create a
.envfile at the project root:
SDK Initialization
The SDK should be initialized as early as possible, preferably in the root component of the application.Example (App.tsx)
- Connects the app to Nemu services
- Activates debug logs for validation during development
- Ensures UTMs captured via deep links are processed correctly
Registering User UID
Before starting the SDK installation and use in your application, you need to define what will be the UID (Unique Identifier) per user to be used. This identifier is defined by the team that will perform the integration. This identifier will be used to link web accesses with the app and vice versa, making tracking extremely precise and efficient. The UID must be a unique value per user in your application. We normally recommend using values already common and existing in your database as identifiers, with the most common option being the user’s email. After the user logs in to the app, register the user’s identifier in the SDK.All user identifiers registered by the SDK are handled securely.
Example after login
Already logged-in users
If the app loads an already authenticated session, register the UID as soon as the user is available:App Install Attribution
Install attribution allows identifying the user’s origin on first app access, even when there is no direct deep link at the moment of opening. Nemu’s SDK automatically collects origin information provided by the app store (Google Play or App Store) to associate the installation with a valid traffic source.When install attribution is used
Install attribution occurs when:- The user installs the app for the first time
- There is no active deep link at the moment of app opening
- The origin is available through store mechanisms
Install attribution is applied only on the first app opening after installation.
What is attributed at installation
When available, the SDK associates the initial session with information such as:- Traffic source (
utm_source) - Medium (
utm_campaign) - Campaign (
utm_campaign) - Other origin parameters provided by the platform
getLastSessionHistory() method.
After installing and opening the app, the origin attributed to the installation will be automatically available for use in events and sales.
Deferred Deep Links
Deferred Deep Links allow the origin of a click to be preserved even when the user:- Clicks on a link with UTMs that leads to the site
- Does not have the app installed yet
- Installs the app
- Opens the app for the first time
When Deferred Deep Links are applied
Deferred deep links are used when:- The app is installed after clicking on a link with UTMs
- The app is opened for the first time after installation
- There is no active deep link at the moment of opening
Complete flow example
- User clicks on a campaign link:
- User is redirected to the app store (Play Store or App Store)
- User installs the app
- User opens the app for the first time
- SDK automatically retrieves UTMs from the original click
- The initial session now contains these UTMs
UTMs recovered via deferred deep link should be used in the same way
as UTMs captured via direct deep links.
Expected behavior
- Deferred deep links are applied only on the first session after installation
- On subsequent accesses, new origins can overwrite the session if there are new deep links
- If there is no attributable origin, the session can be recorded without UTMs
Deep Links
The Nemu React Native SDK already automatically consumes the React NativeLinking API to capture:
- The URL that opened the app
- URLs received while the app is already running
What the SDK does
- Captures URLs via
Linking - Extracts UTMs and
nemu_*parameters - Persists the session origin
- Associates events sent with the captured origin
What needs to be configured in the app
Android
Configure anintent-filter in AndroidManifest.xml for the domain or scheme used by the app.
iOS
Configure Universal Links (Associated Domains) for the domain used by the app.apple-app-site-association file must be available on the configured domain.
Retrieving UTMs from the last session
ThegetLastSessionHistory() method returns the UTMs from the last attributable user’s session.
Usage example
Sending custom events
In addition to automatic session and UTM capture, Nemu’s SDK allows the application to trigger custom events to map important user actions within the app. Initially, events are sent only with the event name, without additional properties.Even so, all events are automatically associated with the session, UTMs, and user’s UID (when available).
sendEvent method
Event sending is done through the sendEvent method, informing only the event name.
Recommended events (market standard)
Below are examples of classic events used in funnel analysis, user journey, and campaign attribution.Page View (screen view)
Fire whenever the user accesses a relevant screen in the app.- Home
- Category
- Product
- Checkout
View Item (product view)
Used when the user views a product screen.Add to Cart
Fire when the user adds an item to the cart.Remove from Cart
Begin Checkout
Indicates that the user started the purchase process.Best practices for events
We recommend using event names in
snake_case,
following known market standards (e.g., GA4).Important recommendations
- Fire events only after the SDK is initialized
- Whenever possible, fire events after the UID is registered
- Use consistent and standardized event names
- Avoid creating multiple names for the same behavior
Automatic association with UTMs
All events sent viasendEvent are automatically associated by the SDK with:
- Last attributable user’s session
- UTMs captured (deep link, deferred deep link, or installation)
- User’s UID (when registered)
After implementation, events become part of the user’s journey in Nemu, allowing more complete behavior and attribution analysis, even without additional properties in the events.
Sending sale with UTMs
Use the UTMs returned by the SDK when sending sale events to Nemu’s API.UTMs must be sent exactly as returned by the SDK.
Testing the integration
1. Enable debug mode
2. Recommended test flow
- Install the clean app
- Open the app via deep link with UTMs
- Check capture logs
- Log in and register the UID
- Retrieve UTMs with
getLastSessionHistory() - Send a sale containing these UTMs