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:
- Open the Unity Editor.
- Select Assets --> Import Package --> Custom Package.
- Select the downloaded SDK package.
Use the Unity Package Manager
To install the Adjust SDK with the Unity Package Manager, follow these steps:
- Select the Package Manager window in the Unity editor.
- Select Add package from git URL.
- 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:
- Select Assets -> External Dependency Manager -> iOS Resolver -> Settings.
- Find the Link frameworks statically option and uncheck it.
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:
- Add the prefab from
Assets/Adjust/Adjust.prefab
to your first scene. - Open the prefab Inspector Menu.
- The prefab menu contains editable fields that control the behavior of the Adjust SDK.
To set up the Adjust SDK, enter the following information:
- Your App Token. See App settings for instructions on how to find your token.
- 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.
- 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.
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
.
If you are using the External Dependency Manager plugin, add the following to your Dependencies.xml
file:
To install the ARR (Android Archive) manually, download it from Maven and add it to the Assets/Plugins/Android
directory.
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.
To record a device's App Set ID, you need to add the following dependency to your Dependencies.xml
file:
To install the ARR (Android Archive) manually, download it from Maven and add it to the Assets/Plugins/Android
directory.
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:
Add the install referrer library as a dependency in a custom build.gradle
file
Download the install referrer library from Maven and put the ARR (Android Archive) file in your Plugins/Android
folder.
Meta referrer integration
The Adjust SDK supports the Meta Install Referrer using the Adjust Meta Install Referrer plugin. See the Unity Meta Install Referrer plugin for integration details.
5. 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.
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.
The iOS post-build process makes the following changes to your generated Xcode project:
- Enables Objective-C exceptions.
Frameworks
You can enable the following frameworks to access iOS features:
AdServices.framework
: Required for Apple Search Ads measurementAdSupport.framework
: Required to read the device IDFAAppTrackingTransparency.framework
: Required to ask for user's consent to be measured and obtain consent statusStoreKit.framework
: Required to communicate with the SKAdNetwork framework.
App Tracking Transparency consent dialog
If you are using the ATT (App Tracking Transparency) wrapper, enter a User Tracking Description message. This displays when you present the ATT consent dialog to your user.
Deep linking
To enable deep linking, add the following information:
- iOS Universal Links Domain: The associated domain used for universal links.
- iOS URL Identifier: Your app's bundle ID.
- iOS URL Schemes: The URL scheme associated with your app.
The Android post-build process checks for an AndroidManifest.xml
file in Assets/Plugins/Android/
. If this file isn't present, it creates a copy from AdjustAndroidManifest.xml
.
Permissions
You can enable the following permissions to access Android features:
android.permission.INTERNET
: Required to connect to the internet.android.permission.ACCESS_NETWORK_STATE
: Required to read the type of network the device is connected to.com.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE
Deprecated: Required to fetch install referrer information via Google Play Store intent.com.google.android.gms.permission.AD_ID
: Required to read the device advertising ID on Android 12 (API level 31) and above. See Google'sAdvertisingIdClient.info
documentation for more information.
Deep linking
To enable deep linking, add the following information:
Android URI Schemes: The destination of your deep link.
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