Get started with the React Native SDK

The Adjust React Native SDK enables you to track 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 our example apps on GitHub.

Important:
The Adjust SDK supports iOS 9 or later and Android API level 9 (Gingerbread) or later.

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:

  1. Download the React Native library using one of the following options.

Github releases page

NPM

  1. Install the CocoaPods dependencies for your iOS app by running the following command on your terminal:
$ cd ios && pod install

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:

import { Adjust, AdjustEvent, AdjustConfig } from 'react-native-adjust';

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:

Javascript
constructor(props) {
    super(props);
    const adjustConfig = new AdjustConfig("{YourAppToken}", AdjustConfig.EnvironmentSandbox);
    Adjust.create(adjustConfig);
}

componentWillUnmount() {
  Adjust.componentWillUnmount();
}

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 Datascape to see test data.
    • Use AdjustConfig.EnvironmentProduction when you have finished testing and are ready to release your app.
Important:
When running tests you should ensure that your environment is set to AdjustEnvironment.sandbox. Change this to AdjustEnvironment.production before you submit your application to the app store.

4. Set up Android devices

Add permissions

The Adjust SDK requires the following permissions. Add them to your AndroidManifest.xml file if they are not already present:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Note:
The Adjust SDK does not require the ACCESS_WIFI_STATE permission if you are targeting the Google Play Store and using Google Play Services. If you don't need it anywhere else in your app, you can remove it.

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 do not target the Google Play Store.

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

See Google's AdvertisingIdClient.Info documentation for more information about this permission.

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.

implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
Note:
The Adjust SDK is not tied to any version of the play-services-ads-identifier dependency. You can use the any version of the Google Play Services library.

Set up Proguard

If you are using Proguard, add the following rules to your Proguard file.

-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
    int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }

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 Tracker, 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.
Note:
Although install referrer is not required, it is highly recommended to improve attribution precision.

Google Play Referrer API

Huawei Referrer API

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 are not madatory 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.

FrameworkDescriptionNotes
AdSupport.frameworkThis framework is needed so that the SDK can access the IDFA value and – prior to iOS 14 – LAT information.If your app is targeting the "Kids" category, you should not implement this framework.
AdServices.frameworkThis framework is needed to handle Apple Search Ads attribution.
StoreKit.frameworkThis framework is needed to access the SKAdNetwork framework and for the Adjust SDK to handle communication with it automatically in iOS 14 or later.
AppTrackingTransparency.frameworkThis framework is needed in iOS 14 and later for the SDK to be able to wrap the user tracking consent dialog and access the user’s consent response.If your app is targeting the "Kids" category, you should not 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 is not 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:

Tip:
If you encounter any issues, email support@adjust.com with all details and logs.

Test Google Play Services integration