LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
    • Acquisition Example
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • SDK Integration
  • Integration by using the Unity Package Manager
  • Integration by importing unitypackage
  • SDK Initialization
  • Specific integration features of certain platforms
  • Windows Standalone
  • Universal Windows Platform (WSA)
  • Android
  • Huawei
  • iOS
  • Apps targeted at children

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 2.0+
  3. SDK Integration

Unity

PreviousWeb SDK ReleasesNextUnreal Engine

Last updated 17 days ago

Was this helpful?

SDK Integration

If you have previously used the Unity SDK version 2+, you need to delete the following files and folders in the "Assets" folder of your project:

To integrate devtodev analytics SDK, you can use one of the two methods: by using the Unity Package Manager (recommended) or by manually importing the unitypackage.

Integration by using the Unity Package Manager

If you integrated the devtodev package manually, then you need to delete the Assets/DevToDev and Plugins/DevToDev folders.

  1. Open the Package Manager (Window → Package Manager), click + in the top left corner and select Add package from git URL.

  2. Copy the repository URL to the input box and click Add.

  3. Wait for the Unity Package Manager to download the package.

  4. For Android projects, add an identification package:

Integration by importing unitypackage

  1. In the Unity Editor menu, open Assets → Import Package → Custom Package.

  2. Select the DTDAnalytics.unitypackage that you have just downloaded.

  3. Click Import.

  4. For Android projects, import an identification package:

SDK Initialization

Create a script with the following code and attach it to the GameObject that will survive the entire life cycle of the app.

using DevToDev.Analytics;
using UnityEngine;

public class DTDObject : MonoBehaviour
{
    void Start()
    { 
#if UNITY_ANDROID
        DTDAnalytics.Initialize("androidAppID");
#elif UNITY_IOS
        DTDAnalytics.Initialize("IosAppID");
#elif UNITY_WEBGL
        DTDAnalytics.Initialize("WebAppID");
#elif UNITY_STANDALONE_WIN
        DTDAnalytics.Initialize("winAppID");
#elif UNITY_STANDALONE_OSX
        DTDAnalytics.Initialize("OsxAppID");
#elif UNITY_WSA
        DTDAnalytics.Initialize("UwpAppID");
#endif
    }
}

You can find the AppID in the settings of the respective app in devtodev (Settings → SDK → Integration → Credentials).

config - an object instance of DTDAnalyticsConfiguration, which is used for specifying additional properties during the initialization.

DTDAnalyticsConfiguration

Parameter

Type

Description

CurrentLevel

Integer

The player level at the moment of devtodev SDK initialization. It’s optional but we recommend using it for improving data accuracy.

UserId

String

A custom user ID assigned by the developer. In the case of default calculation by device IDs, the identifier can be used for searching users in devtodev. In case the project uses calculation by user IDs, the parameter is mandatory because it becomes the principal calculation ID in devtodev.

TrackingAvailability

DTDTrackingStatus (enum)

The property allows or disallows devtodev tracking of the user. By default, it is set to DTDTrackingStatus.Enable. SDK stores the previously assigned value. Pass DTDTrackingStatus.Disable if the user opted out of tracking in line with GDPR.

LogLevel

DTDLogLevel (enum)

The level of logging the SDK activity. The DTDLogLevel.no value is used by default. For troubleshooting during integration it is recommended to set it to DTDLogLevel.Debug, and either switch it off DTDLogLevel.No. Use DTDLogLevel.No in the release version.

ApplicationVersion

String

The app version during the devtodev SDK initialization. Use the property on the WinStandalone platform only. For all other platforms, data is collected automatically.

Example:

var config = new DTDAnalyticsConfiguration
{
    ApplicationVersion = "1.2.3",
    LogLevel = DTDLogLevel.No,
    TrackingAvailability = DTDTrackingStatus.Enable,
    CurrentLevel = 1,
    UserId = "unique_userId"
};
using DevToDev.Analytics;
using UnityEngine;

public class DTDObject : MonoBehaviour
{
    void Start()
    { 
#if UNITY_ANDROID
        DTDAnalytics.Initialize("androidAppID", config);
#elif UNITY_IOS
        DTDAnalytics.Initialize("iOSAppID", config);
#elif UNITY_WEBGL
        DTDAnalytics.Initialize("WebAppID", config);
#elif UNITY_STANDALONE_WIN
        DTDAnalytics.Initialize("winAppID", config);
#elif UNITY_STANDALONE_OSX
        DTDAnalytics.Initialize("OSXAppID", config);
#elif UNITY_WSA
        DTDAnalytics.Initialize("UwpAppID", config);
#endif
    }
}

Specific integration features of certain platforms

Windows Standalone

SDK Activity

The SDK can’t control app activity in case you use Windows Standalone therefore this responsibility is shifted to the developer. While initializing the SDK, the activity starts automatically and after that, the activity status will not auto-change. To track app activity, the developer can use the following methods: DTDAnalytics.StartActivity and DTDAnalytics.StopActivity. It is recommended to use the DTDAnalytics.StopActivity method to stop activity when the app goes into the background or gets closed. You can use the DTDAnalytics.StartActivity method to resume activity when the app gets reopened from the taskbar.

For other platforms, there is no need to manually call the DTDAnalytics.StartActivity and DTDAnalytics.StopActivity methods.

Universal Windows Platform (WSA)

In the version 2019.2, the Executable Only option was added to the Build Type. This option is incompatible with the SDK because the SDK needs access to the project file in order to register the DevToDev.Background service.

Android

-keep class com.devtodev.** { *; }
-dontwarn com.devtodev.**

Huawei

  1. If you imported the DTDGoogle package, delete the imported files Assets\Plugins\DevToDev\Android\DTDGoogleAndroid.dll and Assets\DevToDev\Analytics\Editor\GoogleDependencies.xml

  2. In the assets/Plugins/Android/ folder create a settingsTemplate.gradle file with the following content:

    import java.nio.file.Files
    
    static void enableJetifier(Project project) {
        project.ext['android.useAndroidX'] = true
        project.ext['android.enableJetifier'] = true
    }
    
    static void addBuildscript(Project project) {
        project.buildscript {
            repositories {
                maven { url 'https://plugins.gradle.org/m2/' } 
                maven { url 'https://developer.huawei.com/repo/' }
            }
    
            dependencies {
                classpath 'com.huawei.agconnect:agcp:1.6.5.300'
            }
        }
    }
    
    static void applyPlugins(Project project) {
        if (project.name != 'launcher') return
    
        project.afterEvaluate {
            it.apply plugin: 'com.huawei.agconnect'
        }
    }
    
    static void copyAppGalleryJson(Project project) {
        if (project.name != 'launcher') return
    
        def destinationFile = new File("${project.rootDir}/launcher/agconnect-services.json")
        if (destinationFile.exists()) return
    
        def sourceFile = new File("${project.rootDir}/unityLibrary/devtodev.plugin/agconnect-services.json")
        Files.copy(sourceFile.toPath(), destinationFile.toPath())
    }
    
    gradle.rootProject {
        it.afterEvaluate {
            it.allprojects {
                enableJetifier(it)
                addBuildscript(it)
                applyPlugins(it)
                copyAppGalleryJson(it)
            }
        }
    }
    
    include ':launcher', ':unityLibrary'
    **INCLUDES**

  3. Open Window → devtodev and select Create android plugin folder

  4. Copy the “agconnect-services.json“ file to the Assets\Plugins\Android\devtodev.plugin folder

  5. Open Assets → External Dependency Manager → Android ResolverAssets → External Dependency Manager → Android Resolver and click Resolve

  6. -keep class com.devtodev.** { *; }
    -dontwarn com.devtodev.**
    -keep class com.huawei.hms.**{*;}

iOS

To integrate with Xcode, the SDK uses PostProcessBuild in the DTDPostProcessAnalytics and DTDPostProcessMessaging scripts. If you use custom PostProcessBuild scripts, add them callbackOrder of less than 98 to avoid conflicts.

If you want to disable tracking of advertising identifiers, you need to open the DTDPostProcesssAnalytics.cs file and comment out the line 39: project.AddFrameworkToProject(targetGuid, "AppTrackingTransparency.framework", true);

iOS SDK Signature and Privacy Manifest

Apps targeted at children

When developing and publishing apps targeted at children under 13 years old, you need to ensure special conditions for data processing. Any mobile app aimed at children or intended for users in a region with strict regulations on child online protection, must comply with current laws.

Please study the following requirements:

If your app has to comply with the legal requirements (COPPA), use the following recommendations:

  • Implement the CoppaControlEnable method. The method disables collection of ad IDs and vendor IDs (IDFA, IDFV).

    1. AppTrackingTransparency.framework and all the links pointing to it.

    2. AdSupport.framework and all the links pointing to it.

    3. Depending on the SDK version:

      1. 3.9.0 and older: Set IS_COPPA_ENABLED = true in DTDPostProcessAnalytics.cs (Assets/DevToDev/Analytics/Editor)

  1. Implement the CoppaControlEnable method. The method disables collection of ad IDs and vendor IDs.

  2. If you are using DTDGoogle or DTDHuawei from Unity Package Manager, disable it.

  3. If you are using DTDGoogle.unitypackage, remove the following files:

    Assets\DevToDev\Analytics\Editor\GoogleDependencies.xml
    Assets\Plugins\DevToDev\Android\DTDGoogleAndroid.aar
  4. If you are using DTDHuawei.unitypackage, remove the following files:

    Assets\Plugins\Android\settingsTemplate.gradle
    Assets\Plugins\DevToDev\Android\DTDHuaweiAndroid.aar
    Assets\DevToDev\Analytics\Editor\HuaweiDependencies.xml

Call the CoppaControlEnable method before SDK initialization. If the method was not called, the SDK will work as before.

DTDAnalytics.CoppaControlEnable();
DTDAnalytics.Initialize("App ID", config);

If you work with SDK version 3.5.0 and above, and you want to use Google Ad ID, you need to add . When developing and publishing apps for kids , you do not need . Read more about working with in the .

If you work with SDK version 3.5.0 and above, and you want to use Huawei Ad ID, you need to add . When developing and publishing apps for kids , you do not need . Read more about working with in the .

You can pick a specific SDK version by adding # and a version number at the end of the URL, for example: #v3.3.2

Download DTDAnalytics.unitypackage from .

If you work with SDK version 3.5.0 and above, and you want to use Google Ad ID, you need to import the DTDGoogle.unitypackage. When developing and publishing apps for kids , you do not need the DTDGoogle.unitypackage. Read more about working with in the .

If you work with SDK version 3.5.0 and above, and you want to use Huawei Ad ID, you need to import the DTDHuawei.unitypackage. When developing and publishing apps for kids , you do not need the DTDHuawei.unitypackage. Read more about working with in the .

To resolve external android dependencies, you need to use .

Add the following strings to proguard.txt ():

Select your project in In the “General information” section find “App information” and download the “agconnect-services.json“ file.

Import the DTDHuawei.unitypackage manually from or use Unity Package Manager with .

To add the following rule:

Your app must request tracking authorization before it can get the advertising identifier. See on how to request it.

At Apple introduced new privacy manifests and xcframework signature. More information about it can be found .

USA:

EU:

To comply with , remove from Xcode project:

3.9.1 and newer: Add a new : DTD_COPPA

https://github.com/devtodev-analytics/package_Analytics.git
http://github.com/devtodev-analytics/Unity-sdk-3.0/releases/latest
External Dependency Manager for Unity
read more about Unity proguard here
https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject
GitHub
DTDHuawei package
proguard
the detailed instruction
Children’s Online Privacy Protection Act (COPPA)
General Data Protection Regulation (GDPR) Article 8
Apple’s guidelines
Scripting Define Symbols
devtodev-analytics/package_Google
(COPPA)
devtodev-analytics/package_Google
COPPA
COPPA section
https://github.com/devtodev-analytics/package_Huawei.git
(COPPA)
https://github.com/devtodev-analytics/package_Huawei.git
COPPA
COPPA section
(COPPA)
COPPA
COPPA section
(COPPA)
COPPA
COPPA section
https://github.com/devtodev-analytics/package_Analytics.git
WWDC23
here