Unity
Last updated
Was this helpful?
Last updated
Was this helpful?
This SDK version does not support WebGL. WebGL support will be added in the next releases.
1. Import the DTDAnalytics.unitypackage
from GitHub repository.
2. Create a script with the following code and attach it to the GameObject
that will survive the entire life cycle of the app.
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
or use it only for error handling DTDLogLevel.Error
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:
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.
Add the following strings to proguard.txt (read more about Unity proguard here):
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.