adjust-icon

React Native SDK integration guide

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:

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

    Terminal window
    $ npm install react-native-adjust@5.0.2 --save
  2. Install the CocoaPods dependencies for your iOS app by running the following command on your terminal:

    Terminal window
    $ 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, 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:

constructor(props) {
super(props);
const adjustConfig = new AdjustConfig("{YourAppToken}", AdjustConfig.EnvironmentSandbox);
Adjust.initSdk(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 the dashboard to see test data.
    • Use AdjustConfig.EnvironmentProduction when you have finished testing and are ready to release your app.

4. Set up Android devices

Add permissions

The Adjust SDK requires certain permissions to access information.

  • INTERNET: Added automatically to the Adjust Android SDK. You don't need to add it manually.

You can also add optional permissions that allow you to access additional information.

  • ACCESS_NETWORK_STATE (Optional): You can add this to your AndroidManifest.xml file to read certain parameters that might be useful for you.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

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.

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

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.1.0'

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.
  • Areferrer 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.

Google Play Referrer API

To support the Google Play Referrer API:

  1. Add the following line in the dependencies block of your top-level build.gradle file:

    dependencies {
    implementation 'com.android.installreferrer:installreferrer:2.2'
    }
  2. The installreferrer library is part of Google Maven repository. You need to add Google Maven repository to your app's top-level build.gradle file to build your app:

    allprojects {
    repositories {
    maven {
    url "https://maven.google.com"
    }
    }
    }

Meta referrer integration

The Adjust SDK supports the Meta Install Referrer using the Adjust Meta Install Referrer plugin. See the React Native Meta Install Referrer plugin for integration details.

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.

FrameworkDescriptionNotes
AdSupport.frameworkThis 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.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 andle 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 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. Set up SDK Signature

If you want to use the SDK signature library to secure communications between the Adjust SDK and Adjust's servers, follow the instructions in the SDK signature guide on the Adjust Help Center.

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