adjust-icon

Unity SDK integration guide

The Adjust Unity SDK enables you to record attribution, events, and more in your Unity app. Follow the steps in this guide to set up your app to work with the Adjust SDK.

1. Get the Adjust SDK

To install the Adjust SDK, choose one of the following methods.

Install the Unity package

To use the Adjust SDK in your Unity app, you need to add it to your project. You can download the latest version from the GitHub releases page.

To import the Adjust SDK into your Unity project:

  1. Open the Unity Editor.
  2. Select Assets —> Import Package —> Custom Package.
  3. Select the downloaded SDK package.

Use the Unity Package Manager

To install the Adjust SDK with the Unity Package Manager, follow these steps:

  1. Select the Package Manager window in the Unity editor.
  2. Select Add package from git URL.
  3. Enter the following URL: https://github.com/adjust/unity_sdk.git?path=Assets/Adjust.

2. Install the iOS and Android SDKs

SDK v5 no longer uses the iOS and Android SDKs as binary dependencies. To install the underlying iOS and Android SDKs, you need to use the External Dependency Manager for Unity (EDM4U) to install the packages from CocoaPods and Maven.

To ensure that the Privacy Manifest and frameworks are loaded correctly for iOS, you need to disable static linking. To do this:

  1. Select Assets -> External Dependency Manager -> iOS Resolver -> Settings.
  2. Find the Link frameworks statically option and uncheck it.

A screenshot of the resolver settings menu

3. Integrate the SDK

The Adjust SDK contains a Unity prefab that includes a template game object and an Adjust script. You can use this script to configure the SDK. To open the prefab in the Unity editor:

  1. Add the prefab from Assets/Adjust/Adjust.prefab to your first scene.
  2. Open the prefab Inspector Menu.
  3. The prefab menu contains editable fields that control the behavior of the Adjust SDK.

A screenshot of the Adjust SDK prefab configuration script in the Unity editor.

To set up the Adjust SDK, enter the following information:

  1. Your App Token. See App settings for instructions on how to find your token.
  2. Your Environment:
    • Choose Sandbox 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.
    • Choose Production when you have finished testing and are ready to release your app.
  3. Your Log Level. This controls what logs you receive. See Set log level for more information.

The Adjust SDK starts when the app’s Awake event triggers by default. To override this behavior, check the START SDK MANUALLY option. This enables you to initialize the Adjust SDK by calling Adjust.InitSdk with your config instance as an argument.

AdjustConfig adjustConfig = new AdjustConfig("{YourAppToken}", AdjustEnvironment.Sandbox);
Adjust.InitSdk(adjustConfig);
// ...

4. Set up Android devices

Add Google Play Services

Apps that target the Google Play Store must use the gps_adid (Google Advertising ID) to identify devices. You need to add the play-services-ads-identifier AAR to your project to access the gps_adid.

Collect App Set Identifier

The App Set Identifier is a unique identifier that enables you to measure information from any of your apps that a user has installed on their device. All apps by the same developer share the same App Set ID, meaning you can gather meaningful insights from users across all your apps.

Set up install referrer

The install referrer is a unique identifier which you can use to attribute an app install to a source. The Adjust SDK requires this information to perform attribution. There can gather this information using the Google Play Referrer API.

There are 2 ways to add support for the Google Play Referrer API:

Meta referrer integration

The Adjust SDK supports the Meta Install Referrer. To enable this feature:

  1. Find your Meta app ID in your App Dashboard. See Meta’s App Dashboard documentation for more information.
  2. Add the Meta apps to your AndroidManifest.xml file.
AndroidManifest.xml
<queries>
<package android:name="com.facebook.katana" />
</queries>
<queries>
<package android:name="com.instagram.android" />
</queries>
  1. Set the FbAppId property on your AdjustConfig instance to your app ID.

    AdjustConfig config = new AdjustConfig("{YourAppToken}", AdjustEnvironment.Sandbox, true);
    //...
    config.FbAppId = "{FB_APP_ID_STRING}";
    //...
    Adjust.InitSdk(config);

5. Set up SDK Signature

SDK v5 includes the SDK signature library. Follow the testing guide for iOS and Android to ensure your integration works.

Signature protection is inactive by default. To enable it, you need to:

  1. Enforce signature validation.
  2. Provide your app’s SHA-1 fingerprints prior to testing.

6. Build your app

To complete the app build process, the Adjust Unity package performs custom post-build actions to ensure the Adjust SDK works in your app. This process is performed by the OnPostprocessBuild method in AdjustEditor.cs.

You can configure post-build options to customize your app build.

A screenshot of the Adjust SDK post-build configuration script in the Unity editor.

The output of the process is shown in the Unity IDE console window.

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 AdjustEnvironment.Sandbox.
  • Add a sandbox filter to your Adjust dashboard results.
  • Set your log level to AdjustLogLevel.Verbose.

Test Google Play Services integration

To test that the Adjust SDK can receive a device’s Google Advertising ID, set the log level to AdjustLogLevel.Verbose and the environment to AdjustEnvironment.Sandbox. Start your app and measure a session or an event. The SDK logs the gps_adid (Google Play Services Advertiser ID) parameter if it has read the advertising ID.

If you are having issues retrieving the Google Advertising ID, open an issue in the GitHub repository or contact support@adjust.com.