Prerequisites
Complete these prerequisite steps before installing the Singular Unity SDK to ensure a smooth integration process.
Required Prerequisites:
- Complete planning steps: Follow the guide in Integrating a Singular SDK: Planning and Prerequisites. These steps are mandatory for any Singular SDK integration.
- Check dependency manager: Verify if your project uses Google EDM4U (External Dependency Manager for Unity). Learn more about Google EDM4U.
-
Upgrading from .unitypackage? If you're migrating from the legacy
.unitypackageto the newUPMpackage, read the upgrade instructions before proceeding.
Installation
Installing via Unity Package Manager (UPM)
The Singular Unity SDK is installed through Unity Package Manager using Git URLs. Follow these steps to add the SDK to your project.
Installation Steps
- Open Package Manager: In Unity, navigate to Window > Package Manager.
- Add package from Git: Click the [+] button in the top-left corner and select "Add package from git URL".
-
Enter the Git URL:
-
For Standard SDK: Enter
https://github.com/singular-labs/Singular-Unity-SDK.git -
For Kids SDK: Enter
https://github.com/singular-labs/Singular-Unity-SDK.git#kids
-
For Standard SDK: Enter
- Complete installation: Click "Add" to install the SDK package.
Not Using Google EDM4U? If your project doesn't use the External Dependency Manager, you must manually download and add native dependencies.
Manual Dependency Installation
-
Download dependencies: Download the appropriate
Plugins.zipfile from Singular's S3 bucket:-
Standard SDK (v5.6.0):
Download Standard SDK Plugins -
Kids SDK (v5.6.0):
Download Kids SDK Plugins
-
Standard SDK (v5.6.0):
- Extract to Assets: Extract the downloaded files and move them to Assets > Plugins in your Unity project.
-
Configure iOS framework: Navigate to
Assets > Plugins > iOS and select
Singular.xcframework. - Embed binary: In the Inspector pane, check the option "Add to Embedded Binaries".
Android Configuration Tips
Configure your Android build settings to ensure proper SDK functionality. Unity provides multiple ways to customize Android manifests and Gradle files.
You can modify the AndroidManifest using one of two methods:
Method 1: Unity Custom Manifest
- Navigate to File > Build Settings > Player Settings > Publishing Settings.
- Enable "Custom Main Manifest" under the Publishing Settings section.
-
Unity generates a default
AndroidManifest.xmlfile at Assets/Plugins/Android/AndroidManifest.xml. - Edit this file to add required permissions and configurations.
Source: Unity Android Manifest Documentation
Method 2: Android Studio
- Export your project from Unity using File > Build Settings > Export Project.
- Open the exported project in Android Studio.
-
Edit the
AndroidManifest.xmlfile directly in Android Studio.
Method 1: Unity Custom Template
- Navigate to File > Build Settings > Player Settings > Publishing Settings.
- Enable "Custom Gradle Template" under the Publishing Settings section.
-
Unity generates a
mainTemplate.gradlefile at Assets/Plugins/Android/mainTemplate.gradle. - Add your custom Gradle configurations to this file.
Source: Unity Gradle Overview Documentation
Method 2: Android Studio
- Export your project from Unity.
- Open the project in Android Studio.
-
Edit the app's
build.gradlefile directly.
When building Android apps in Unity, you may encounter "Duplicate class" errors caused by multiple SDKs including the same transitive dependencies. This commonly occurs with the Android Vending Licensing library when using both AppLovin SDK and Singular SDK.
Example Error:
Duplicate class com.android.vending.licensing.ILicensingService found in modules
applovin-sdk-13.5.0.aar -> jetified-applovin-sdk-13.5.0-runtime (com.applovin:applovin-sdk:13.5.0)
and singular_sdk-12.10.0.aar -> jetified-singular_sdk-12.10.0-runtime (com.singular.sdk:singular_sdk:12.10.0)
Solution 1: Using External Dependency Manager (EDM4U)
If your project uses External Dependency Manager for Unity (recommended), add exclusion rules to your Dependencies XML file.
-
Locate your
*Dependencies.xmlfile in your Unity project (typically inAssets/Editoror a similar location). - Add an exclusion rule to one of the SDK dependencies:
<dependencies>
<androidPackages>
<androidPackage spec="com.applovin:applovin-sdk:13.5.0">
<androidSdkPackageIds>
<exclude group="com.android.vending" module="licensing"/>
</androidSdkPackageIds>
</androidPackage>
<androidPackage spec="com.singular.sdk:singular_sdk:12.10.0" />
</androidPackages>
</dependencies>
Note: This approach is more persistent than modifying Gradle templates, as Android Resolver may overwrite custom template changes during resolution.
Solution 2: Using Custom Gradle Templates
If you're not using EDM4U, apply exclusion rules directly in your Gradle configuration files.
- Navigate to File > Build Settings > Player Settings > Publishing Settings.
- Enable "Custom Main Gradle Template" or "Custom Launcher Gradle Template".
-
Open
Assets/Plugins/Android/mainTemplate.gradle(orlauncherTemplate.gradle). - Add the exclusion rule to your dependencies block:
dependencies {
implementation('com.applovin:applovin-sdk:13.5.0') {
exclude group: 'com.android.vending', module: 'licensing'
}
implementation 'com.singular.sdk:singular_sdk:12.10.0'
}
Alternative: Apply a global exclusion by adding this after your dependencies block:
configurations.all {
exclude group: 'com.android.vending', module: 'licensing'
}
Verify Resolution
- After applying the exclusion, clean your project by deleting Library/Bee and Temp folders.
- Rebuild your Android project in Unity.
- Verify the duplicate class error no longer appears in the build output.
Why This Works: Both SDKs bundle the same Android licensing library as a transitive dependency. The exclusion tells Gradle to use only one copy, resolving the conflict.
If your project uses ProGuard for code obfuscation, add the
following
keep rules to your proguard-unity.txt file to
prevent
the Singular SDK from being stripped:
-keep class com.singular.sdk.** { *; }
-keep public class com.android.installreferrer.** { *; }
-keep public class com.singular.unitybridge.** { *; }
iOS Configuration Tips
Configure iOS-specific settings to enable proper attribution, deep linking, and testing functionality.
After building your Unity project for iOS and before building in Xcode, update your CocoaPods dependencies to ensure you have the latest SDK versions.
cd /path/to/your/ios/project
pod repo update
pod update
For testing your integration, log the IDFV (Identifier for Vendor) to quickly add your test device in the Singular SDK Console.
Add IDFV Logging
- Open your Xcode project after building from Unity.
- Navigate to Classes > UnityAppController.mm.
-
Find the
applicationDidBecomeActivemethod. - Add the following code to log the IDFV:
// Log IDFV for testing
NSLog(@"Singular === IDFV: %@", [[[UIDevice currentDevice] identifierForVendor] UUIDString]);
- Build and run your app in Xcode.
- Check the Xcode console logs for the IDFV output.
- Copy the IDFV and add it as a test device in the Singular SDK Console.
Enable Universal Links for deep linking by configuring Associated Domains in your Xcode project.
Deep Link Setup Steps
- Add Associated Domain: In Xcode, navigate to your app target's Signing & Capabilities tab.
- Enable capability: Click [+] Capability and add "Associated Domains".
-
Add domain: Add your Singular tracking
domain
in the format:
applinks:yourdomain.sng.link - Configure Team ID: In the Singular dashboard, navigate to your app's settings and add your Apple Team ID. This allows Singular to generate and host the Apple App Site Association (AASA) file required for Universal Links.
Important: Without properly configured Associated Domains and Team ID, Universal Links will not work and users won't be able to open your app from Singular tracking links.
Integrate the SDK
Create the SingularSDK GameObject
The Singular SDK requires a GameObject in your Unity scene hierarchy to function. You can add this GameObject using either the provided prefab or by creating it manually.
Add Prefab to Scene
- In the Project pane, navigate to Packages > Singular > SingularSDK > Prefabs.
- Drag the SingularSDKObject prefab into your Hierarchy pane.
- The prefab is now ready to configure in the Inspector.
Manual GameObject Creation
- In the Hierarchy pane, right-click and select Create Empty.
-
Name the GameObject
SingularSDKObject(exact name required). - With the GameObject selected, navigate to the Inspector pane.
- Click Add Component.
- Search for "Singular" and select the Singular SDK script component.
Critical: The GameObject must be named
exactly
SingularSDKObject for the SDK to function
properly.
Configure SDK Settings
Configure your SDK credentials and initialization settings through the Unity Inspector. Your API Key and Secret are required for the SDK to communicate with Singular's servers.
Add API Credentials
- Select SingularSDKObject: Click on the SingularSDKObject in your Hierarchy.
- Locate credentials: Log into your Singular account and navigate to Developer Tools > SDK Integration > SDK Keys.
- Copy keys: Copy your SDK Key and SDK Secret.
- Paste in Inspector: In Unity's Inspector pane, paste the credentials into the Singular API Key and Singular API Secret fields.
Critical: Do NOT use the Singular Reporting API Key. Only use the SDK-specific API Key and Secret from the SDK Integration page. Using the wrong credentials will prevent data from being sent to Singular.
Verify Your Integration: After configuration, test your implementation using the Singular SDK Console to ensure events are being tracked correctly.
Default Inspector Settings
The SingularSDKObject comes with sensible defaults. Understanding these settings helps you customize the SDK behavior for your app's requirements.
- Initialize On Awake: Enabled by default. The SDK initializes automatically when the GameObject awakens. Disable this if you need to delay initialization for privacy consent or other requirements.
- SKAN Enabled: Enabled by default (iOS only). Enables SKAdNetwork attribution in Managed Mode, where Singular automatically updates conversion values based on your configured conversion model.
- Wait For Tracking Authorization: Set to 0 (disabled). If your app shows the iOS App Tracking Transparency (ATT) prompt, set this to 300 seconds. This delays the SDK session until the user responds to the ATT prompt, ensuring the IDFA can be captured if consent is granted. Leave at 0 if not using ATT.
- Enable Logging: Enabled by default. Outputs SDK debug logs to help with integration and troubleshooting. Should be disabled in production builds. Works with the Log Level setting (see below).
-
Log Level: Set to 3 (Info) by default.
Controls
logging verbosity. Lower numbers produce more verbose
logs:
// Based on Android Logger log levels public enum LogLevel { Verbose = 2, // Most verbose Debug = 3, Info = 4, // Default Warn = 5, Error = 6, Assert = 7 // Least verbose }Note: Detailed logs are primarily available on Android.
- DDL Timeout Sec: Set to 0 (uses 60-second default). Determines how long the SDK waits for deferred deep link data from the server. The server stops searching after this timeout if no deferred deep link is found.
- Session Timeout Sec: Set to 0 (uses 60-second default). Defines how long the app can be backgrounded before the SDK creates a new session upon returning to the foreground.
- Shortlink Resolve Timeout: Set to 0 (uses 10-second default). Maximum time to wait for short link resolution. Protects user experience by preventing long waits if a short link can't be resolved.
Additional Configuration Options
As of June 18th, 2025: Meta's Advanced Mobile Measurement (AMM) removes the need for implementing Meta Install Referrer. If AMM reporting is enabled, you do not need to configure Meta Install Referrer.
If you need to support the legacy Meta Install Referrer attribution method, add your Facebook App ID to the SingularSDKObject configuration.
Configuration Steps
- Select the SingularSDKObject in your scene hierarchy.
- In the Inspector pane, locate the "Facebook App ID" field.
- Enter your Facebook App ID (find this in your Facebook Developer Console).
Additional Resources:
Initialize the SDK
Privacy Compliance: When implementing the Singular SDK, comply with privacy laws in your operating regions, including GDPR, CCPA, COPPA, and others. For guidance, see SDK Opt-In and Opt-Out Practices.
Initialize the Singular SDK every time your app launches. SDK initialization is essential for all Singular attribution functionality and creates a new session for calculating user retention metrics.
Automatic Initialization
By default, the SingularSDK.cs script automatically initializes
the SDK when your scene loads through Unity's Awake() method.
No additional code is required if Initialize On Awake
is enabled in the Inspector.
Manual Initialization
If you need to initialize the SDK at a specific time (for example, after obtaining user consent), disable automatic initialization and call the initialization method manually.
Manual Initialization Setup
- Select the SingularSDKObject in your scene hierarchy.
- In the Inspector pane, uncheck Initialize On Awake.
-
Call
SingularSDK.InitializeSingularSDK()in your code when ready to initialize.
InitializeSingularSDK Method
Use this method to manually initialize the SDK when automatic initialization is disabled.
using UnityEngine;
using Singular;
public class GameInitializer : MonoBehaviour
{
void Start()
{
// Perform any required setup (e.g., consent management)
CheckUserConsent();
// Initialize Singular SDK after consent is obtained
// SDK Key and Secret are configured on the SingularSDKObject
SingularSDK.InitializeSingularSDK();
}
void CheckUserConsent()
{
// Your consent logic here
}
}
Thread Safety: Always call Singular Unity SDK methods from the same thread used for other Unity API calls. The SDK is not thread-safe across multiple threads.
Advanced Configuration
Configure Session Timeout
Customize how long your app can remain in the background before the SDK creates a new session when the app returns to the foreground.
Session Timeout Configuration
The default session timeout is 60 seconds. To change this value:
- Select the SingularSDKObject in your scene hierarchy.
- In the Inspector pane, locate the Session Timeout Sec field.
- Enter your desired timeout value in seconds (e.g., 120 for 2 minutes).
- Leave at 0 to use the default 60-second timeout.
Best Practice: Consider your app's typical usage patterns when setting session timeout. Games with frequent short sessions may benefit from a shorter timeout, while productivity apps may need longer timeouts.
Upgrading from .unitypackage to UPM
If you're migrating from the legacy .unitypackage installation
method to the modern Unity Package Manager (UPM) approach, follow these
critical upgrade steps.
Critical: You must manually remove all existing Singular SDK files before installing the UPM package. Failure to do so will cause conflicts and build errors.
Upgrade Procedure
Complete these steps in order before installing the SDK via Unity Package Manager:
1. Remove Code Files
Navigate to your project's /Code
folder (typically Assets/Singular/Code)
and delete all Singular-related C# scripts.
2. Remove Android Dependencies
Navigate to /Plugins/Android and remove the following Singular files:
-
All
.aarfiles with "singular" in the name -
All
.jarfiles with "singular" in the name -
singular-sdk.aar -
install-referrer-*.aar -
singular-unitybridge.aar
3. Remove iOS Dependencies
Navigate to /Plugins/iOS and remove the following Singular files:
-
All
.hheader files (e.g.,SingularSDK.h) -
All
.mimplementation files (e.g.,SingularUnityBridge.m) -
Singular.xcframeworkfolder
Important: Only remove Singular-specific files. Be careful not to delete other plugin files your project may depend on.
4. Verify Clean State
- After removing files, close Unity completely.
- Delete the Library folder in your project directory to force Unity to reimport assets.
- Reopen your Unity project.
- Wait for Unity to finish reimporting assets.
- Verify there are no compilation errors before proceeding with UPM installation.
5. Install UPM Package
Now you're ready to install the Singular SDK via Unity Package Manager. Follow the UPM installation instructions at the top of this guide.