Unity
SDK Integration
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.
Open the Package Manager (Window → Package Manager), click + in the top left corner and select Add package from git URL.
Copy the repository URL https://github.com/devtodev-analytics/package_Analytics.git to the input box and click Add.
Wait for the Unity Package Manager to download the package.
For Android projects, add an identification package:
If you work with SDK version 3.5.0 and above, and you want to use Google Ad ID, you need to add devtodev-analytics/package_Google. When developing and publishing apps for kids (COPPA), you do not need devtodev-analytics/package_Google. Read more about working with COPPA in the COPPA section.
Integration by importing unitypackage
Download DTDAnalytics.unitypackage from http://github.com/devtodev-analytics/Unity-sdk-3.0/releases/latest.
In the Unity Editor menu, open Assets → Import Package → Custom Package.
Select the DTDAnalytics.unitypackage that you have just downloaded.
Click Import.
For Android projects, import an identification package:
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 (COPPA), you do not need the DTDGoogle.unitypackage. Read more about working with COPPA in the COPPA section.
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)

Android
To resolve external android dependencies, you need to use External Dependency Manager for Unity.
Add the following strings to proguard.txt (read more about Unity proguard here):
-keep class com.devtodev.** { *; }
-dontwarn com.devtodev.**
Huawei
Select your project in https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myProject In the “General information” section find “App information” and download the “agconnect-services.json“ file.
If you imported the DTDGoogle package, delete the imported files Assets\Plugins\DevToDev\Android\DTDGoogleAndroid.dll and Assets\DevToDev\Analytics\Editor\GoogleDependencies.xml
Import the DTDHuawei.unitypackage manually from GitHub or use Unity Package Manager with DTDHuawei package.
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**
Open Window → devtodev and select Create android plugin folder
Copy the “agconnect-services.json“ file to the Assets\Plugins\Android\devtodev.plugin folder
Open Assets → External Dependency Manager → Android ResolverAssets → External Dependency Manager → Android Resolver and click Resolve
To proguard add the following rule:
-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.
iOS SDK Signature and Privacy Manifest
At WWDC23 Apple introduced new privacy manifests and xcframework signature. More information about it can be found here.
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.
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).To comply with Apple’s guidelines, remove from Xcode project:
AppTrackingTransparency.framework
and all the links pointing to it.AdSupport.framework
and all the links pointing to it.Depending on the SDK version:
3.9.0 and older: Set
IS_COPPA_ENABLED = true
inDTDPostProcessAnalytics.cs
(Assets/DevToDev/Analytics/Editor
)3.9.1 and newer: Add a new Scripting Define Symbols: DTD_COPPA
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);
Last updated
Was this helpful?