You can send data from your Unity application to Treasure Data, using our Unity SDK library. In this way, you don't have to install anything on your server-side to track the mobile app activities.
This topic includes:
To support compliance with national and global data privacy requirements such as the European General Data Privacy Regulation, our SDK provides methods that control the collection and tracking of personal data and metadata in applications and websites. When your company defines data privacy policies around personal data, you can use these methods in your code to implement default data collection behaviors, and add controls for individuals to use to manage data collection and privacy themselves.
Customers of Treasure Data must ensure that their usage of the SDK, including its use that collects personal data, complies with the legal agreement that governs access to and use of the Treasure Data service, including specifically:
Terms of Service
Privacy Statement for Customer Data
Basic knowledge of Unity Development
Basic knowledge of Treasure Data
Our Unity SDK is available through Github. Check the repository to ensure that you have the most recent SDK.
Install the Library
Download the most recent version of our Unity package.
Import it into your Unity project using Assets > Import Package > Custom Package.
For iOS Application development
On Xcode, you must complete the following steps:
In Build Phases > Link Binary With Libraries.
In Build Phases > Compile Sources.
Add -fno-objc-arc compile flag to NativePlugin.mm
Initialize the Library
Next, initialize the library in your app as follows.
When to upload and how often to upload buffered events depends on the characteristics of your application. Good times to upload include:
When the current screen is closing or moving to background
When closing the application
Send Events to the Cloud
Next, call the
AddEvent() function at the appropriate time within your applications. The following example shows an event is sent to the table
table_b within the database
IP whitelist won't be applied to any import from iOS or Android SDK. Also we've seen a lot of cases where a lot of iOS or Android devices have an invalid timestamp (like 1970/01/01), so we're currently ignoring the log which has a timestamp older than 7 days, and newer than 3 days ahead.
Tracking Application Lifecycle Events
Optionally, you can enable the Unity SDK to automatically capture app lifecycle events (disabled by default). You must explicitly enable this option. You can set the target table through
There are 3 kinds of event that are tracked automatically:
These events are captured along with relevant metadata depends on the specific type of event:
Tracking In-App Purchase Events
If enabled, Treasure Data SDK can automatically track IAP events without having to listen and call
addEvent yourself. Enable this tracking feature by:
Although always disabled by default (unlike the other options: app lifecycle events or custom events, this choice is not persisted), you could explicitly disable this feature by:
Depends on the native platform in which the game is running on, the event's schema could be different. On Android, the IAP event's columns consist of:
While on iOS:
For further details of these columns' value see:
Treasure Data Android SDK - IAP Tracking
Treasure Data iOS SDK - IAP Tracking
Respecting your user's privacy is critical to any business. Treasure Data SDK can opt-out all events tracking for a particular device and de-identify users by resetting (or disabling completely) the
td_uuid. You can change the
td_uuid. to a different id for all subsequent events:
Unlike other option flags, enable/disableCustomEvent and enable/disableAppLifecycleEvent are persistent settings, which means that the settings survive across app launches. It is important to use the disableCustomEvent and disableAppLifecycleEvent calls whenever your users indicate that they don’t want to be tracked. It is not necessary to call the options on every Treasure Data client setup.
resetUniqId also adds an audit event to the
Retry Uploading and Deduplication
The SDK imports events in one style with the combination of these features: Deduplication is a best effort system that identifies a duplicate record if a record with the same identifier is seen in the same dataset, within the last hour at most or within the last 4096 records, whichever comes first.
Deduplication is a best effort system that identifies a duplicate record if a record with the same identifier is seen in the same dataset, within the last hour at most or within the last 4096 records, whichever comes first.