The Adjust React Native SDK enables you to measure attribution, events, and much more in your React Native app. Follow the steps in this guide to set up your app to work with the Adjust SDK. You can also check out the example apps on GitHub.
1. Add the SDK to your project
To use the Adjust SDK in your React Native app, you need to add it to your project. Follow these steps to add it:
- Download the React Native library using one of the following options.
Run the following command on your terminal:
You can download the latest version of the SDK from Adjust’s React Native SDK GitHub releases page.
- Install the CocoaPods dependencies for your iOS app by running the following command on your terminal:
2. Integrate the SDK
To integrate the SDK with your project, you must import Adjust’s SDK configuration to your main app Javascript file.
Add the following line at the beginning of your app’s .js
file:
3. Initialize the Adjust SDK
Make sure you initialize the Adjust SDK as soon as possible in your React Native app. To do this, initialize your config object with your app token and the environment you want to run your application in. Add the following lines of code to your app’s .js
file:
Pass the AdjustConfig
arguments:
- Replace
{YourAppToken}
with your token. See App settings for instructions on how to find your token. - Choose your Environment:
- Use
AdjustConfig.EnvironmentSandbox
if you are testing your app and want to send test data. You need to enable sandbox mode in the dashboard to see test data. - Use
AdjustConfig.EnvironmentProduction
when you have finished testing and are ready to release your app.
- Use
4. Set up Android devices
Add permissions
The Adjust SDK requires certain permissions to access information. Add them to your AndroidManifest.xml
file if they’re not already present:
The Adjust SDK includes the com.google.android.gms.AD_ID
permission by default in version 4.32.0 and above. You can remove it by adding a remove
directive if need to make your app COPPA-compliant or if you don’t target the Google Play Store.
Add Google Play Services
Apps that target the Google Play Store must use the Google Advertising ID (gps_adid
) to identify devices. To do this, Add the following dependency to the dependencies
section of your build.gradle
file.
Set up Proguard
If you are using Proguard, add the following rules to your Proguard file.
Set up install referrer
The install referrer is an attribution mechanism you can use to attribute an app install to a source. It consists of two parts:
- A set of APIs from these app stores that allow developers to retrieve referral content in their apps.
- A
referrer
parameter that app stores, such as Google Play and Huawei App Gallery, accept in their app page URLs on their store websites. Here is how the referrer parameter is populated:- When a user clicks on an Adjust link, the Adjust server passes a unique identifier called
reftag
. This identifier is assigned to the click and into the referrer parameter. To know more about reftag, visit Reftag. - When you run Google Ads campaigns, Google passes a unique identifier called
gclid
into the referrer parameter. You must have Auto-tagging turned on in your Google Ads account.
- When a user clicks on an Adjust link, the Adjust server passes a unique identifier called
Google Play Referrer API
To support the Google Play Referrer API:
- Add the following line in the dependencies block of your top-level
build.gradle
file:
- The
installreferrer
library is part of Google Maven repository. You need to add Google Maven repository to your app’s top-levelbuild.gradle
file to build your app:
- If you are using Proguard, make sure you have added the following setting in your Proguard file:
Huawei Referrer API
As of v4.22.0, the Adjust SDK supports install measurement on Huawei devices using Huawei App Gallery v10.4 and later. You don’t need to make any changes to start using the Huawei Referrer API.
Meta referrer integration
The Adjust SDK supports the Meta Install Referrer in v4.37.0 and above. To enable this feature:
-
Find your Meta app ID in your App Dashboard. See Meta’s App Dashboard documentation for more information.
-
Pass your App ID as a
string
argument to theAdjustConfig.setFbAppId
method.
5. Add iOS frameworks
The Adjust SDK is able to get extra information when you include certain iOS frameworks in your app. These frameworks enable certain SDK features, but they’re not mandatory for the SDK to work normally. You can add the frameworks and then mark them as optional in Project Settings —> Build Phases —> Link Binary With Libraries.
Framework | Description | Notes |
---|---|---|
AdSupport.framework | This framework is needed so that the SDK can access the IDFA value and, before iOS 14, AT information. | If your app is targeting the “Kids” category, you shouldn’t implement this framework. |
AdServices.framework | This framework is needed to handle Apple Search Ads attribution. | |
StoreKit.framework | This framework is needed to access the SKAdNetwork framework and for the Adjust SDK to andle communication with it automatically in iOS 14 or later. | |
AppTrackingTransparency.framework | This framework is needed in iOS 14 and later for the SDK to be able to wrap he user ATT consent dialog and access the user’s consent response. | If your app is targeting the “Kids” category, you shouldn’t implement this framework. |
6. Add the Adjust SDK signature
You can use the Adjust SDK signature to sign all communications sent by the Adjust SDK. This enables Adjust’s servers to detect and reject any install activity that isn’t legitimate.
To get started with the Adjust SDK signature, contact your Technical Account Manager or support@adjust.com.
7. Test your integration
The Adjust SDK provides tools for testing and troubleshooting issues with your integration. To test your setup:
- Set your environment to
AdjustConfig.EnvironmentSandbox
. - Add a sandbox filter to your Adjust dashboard results.
- Set your log level to
AdjustConfig.LogLevelVerbose
.
Test Google Play Services integration
To test that the Adjust SDK can receive a device’s Google Advertising ID, set the log level to AdjustConfig.LogLevelVerbose
and the environment to AdjustConfig.EnvironmentSandbox
. Start your app and record a session or an event. The SDK logs the gps_adid
parameter if it has read the advertising ID.
If you’re having issues retrieving the Google Advertising ID, open an issue on the SDK GitHub repository or contact support@adjust.com.