Requirements
- minSdkVersion: 21 (Android 5.0)
- targetSdkVersion: 34 (Android 14)
- Kotlin version: 1.8.22 or higher
- Java compatibility: Java 8
Installation
To install Nemu SDK in your application built with Kotlin, it is mandatory to add the SDK dependency in your build.gradle.kts (or .gradle) file. Additionally, add dependencies to retrieve the origin from your app installations on Google Play.onCreate of your application, providing the Nemu pixel ID and your Nemu SDK key as arguments.
As a suggestion, you can use a Gradle plugin (like dotenv-gradle) to load a .env with content like:
build.gradle.kts:
Registering UID to the SDK session
For total security and integrity of your application user data,
all UIDs registered by our SDK are encrypted before being
stored on our servers.
setUserId() method, passing as an argument the defined UID of the user who just completed the login process. See this example:
Application’s onCreate() or right after loading the saved user (e.g., after sessionManager.loadUser()).
Retrieving UTMs when sending sale event to Nemu API
ThegetLastSessionHistory() method returns an object containing the UTMs from the user’s last session. Use this object when sending the sale information to the Nemu API. See the example below:
Testing the SDK and ensuring everything is right
To test the complete flow and ensure your integration is working correctly, you can execute the simple steps below:1. Initialize the SDK in DEBUG mode
To view logs generated by the SDK itself, you can enable it by passing the optional argumentisDebugMode as true to the SDK initialization method where it is being called.
2. Click on a deep link that redirects to the app
If your application is not yet configured to receive deep links, click here to learn how to configure them. In your emulation tool, access a link that redirects to your app with a set of UTMs, example:https://myapp.com?utm_source=nemu&utm_medium=medium-test&utm_campaign=campaign-test&utm_content=content-test
3. Access your application and check if the SDK was initialized correctly through the logs
After the app runs, check your application logs. If everything is configured correctly, we will see the 3 logs below:A quick explanation about each log:
- Connection to Nemu: Shows that Nemu’s SDK was able to correctly connect to Nemu servers through valid pixel ID and SDK token
- UTM Extraction: Displays that the SDK was able to receive and correctly store the UTMs defined in the DeepLink
- UID Registered: Informs that the SDK was able to assign the UID passed to the current access
4. Check if UTMs are being correctly retrieved when calling the getLastSessionHistory() method
As a final step, check if when calling the getLastSessionHistory() method UTMs are being correctly retrieved. With debug mode enabled, you will be able to see the returned object in the logs, but you can complementarily add logs in the section where the method is being executed for validations:
"||nemu_xiI85afzrP" is automatically inserted. This string represents Nemu’s internal session identifier and should be sent as part of utm_content when sending sales to the Nemu API.