The WiseTrack Unity package provides a solution to accelerate your game or app’s growth, helping you increase users, boost revenue, and reduce costs within the Unity environment.
- Requirements
- Installation
- Initialization
- Basic Usage
- Advanced Usage
- Example Project
- Troubleshooting
- License
- Unity 2019.4 or later
- Kotlin version 1.9.0 or later
- Android API 21 (Lollipop) or later
- External Dependency Manager for Unity (EDM4U) installed
To integrate the WiseTrack Unity Package into your Unity project, follow these steps:
-
Install External Dependency Manager for Unity (EDM4U): The WiseTrack Unity Package requires EDM4U to manage Android and iOS dependencies. Follow the installation instructions provided in the EDM4U GitHub repository.
-
Add the WiseTrack Package: You can add the package via Unity Package Manager (UPM) or directly from a Git URL.
- Open Unity and navigate to
Window > Package Manager. - Click the
+button in the top-left corner and selectAdd package from git URL. - Enter the following URL (replace with the actual GitHub URL for your package):
https://github.com/wisetrack-io/unity-sdk.git - Click
Add. Unity will download and install the package. - If prompted, resolve dependencies using EDM4U by navigating to
Assets > External Dependency Manager > Android Resolver > Force Resolve.
- Clone or download the WiseTrack Unity package repository from GitHub.
- Extract the contents to your project’s
Assets/Plugins/WiseTrackfolder. - Open Unity, and EDM4U will automatically detect and resolve dependencies. If not, manually trigger resolution via
Assets > External Dependency Manager > Android Resolver > Resolve. - Ensure all required dependencies are included in your project (see Feature-Specific Dependencies).
- Go to the Releases section of the repository.
- Download the latest
.unitypackagefile. - In Unity, navigate to
Assets > Import Package > Custom Package…. - Select the downloaded
.unitypackageand clickImport. - Once imported, make sure EDM4U is installed in your project.
- Trigger dependency resolution via
Assets > External Dependency Manager > Android Resolver > Resolveif needed.
- Open Unity and navigate to
-
Configure Android: Ensure your
minSdkVersionis set to 21 or laterIf your app targets non-Google Play stores (e.g., CafeBazaar, Myket), add these permissions to
Assets/Plugins/Android/AndroidManifest.xml:<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
Note: to enable
AndroidManifest.xmlensureCustom Main Manifestis checked in Project Settings.The WiseTrack Unity Package supports additional Android features that require specific dependencies. Add only the dependencies for the features you need in
Assets/Plugins/Android/mainTemplate.gradleunder thedependenciesblock. If you encounter issues withappsetorads-identifierdependencies, consider using the WiseTrackIdentifier Unity Package as an alternative.-
Google Advertising ID (Ad ID): Enables retrieval of the Google Advertising ID via
GetAdId().implementation 'com.google.android.gms:play-services-ads-identifier:18.2.0' -
AppSet ID: Provides additional device identification for analytics.
implementation 'com.google.android.gms:play-services-appset:16.1.0' -
Open Advertising ID (OAID): Enables OAID for devices without Google Play Services (e.g., Chinese devices) via
WTInitialConfigwithoaidEnabled: true.implementation 'io.wisetrack:sdk:oaid:2.0.0' // Replace with the latest version
-
Huawei Ads Identifier: Enables Ad ID retrieval on Huawei devices.
repositories { maven { url 'https://developer.huawei.com/repo/' } } dependencies { implementation 'com.huawei.hms:ads-identifier:3.4.62.300' }
-
Referrer Tracking: Enables referrer tracking for Google Play and CafeBazaar via
WTInitialConfigwithreferrerEnabled: true.implementation 'io.wisetrack:sdk:referrer:2.0.0' // Replace with the latest version implementation 'com.android.installreferrer:installreferrer:2.2' // Google Play referrer implementation 'com.github.cafebazaar:referrersdk:1.0.2' // CafeBazaar referrer
-
Firebase Installation ID (FID): Enables retrieval of a unique Firebase Installation ID.
implementation 'com.google.firebase:firebase-installations:17.2.0'To use Firebase, register your app in the Firebase Console:
- Add your package name (e.g.,
com.example.app). - Download the
google-services.jsonfile and place it inAssets/Plugins/Android/. - Update
Assets/Plugins/Android/mainTemplate.gradle:buildscript { dependencies { classpath 'com.google.gms:google-services:4.4.1' // Or latest version } }
- Apply the Google Services plugin:
apply plugin: 'com.google.gms.google-services'
- Add your package name (e.g.,
-
-
Rebuild the Project: Build your project to ensure all dependencies are correctly integrated:
- In Unity, go to
File > Build Settingsand select your target platform. - Click
BuildorBuild and Run.
- In Unity, go to
To start using the WiseTrack Unity Package, initialize it with a configuration object in your game’s startup script.
using UnityEngine;
using WiseTrack.Runtime;
public class GameInitializer : MonoBehaviour
{
void Awake()
{
var config = new WTInitialConfig
{
AppToken = "your-app-token",
UserEnvironment = WTUserEnvironment.Production, // Use Sandbox for testing
AndroidStore = WTAndroidStore.GooglePlay,
iOSStore = WTIOSStore.AppStore,
LogLevel = WTLogLevel.Warning
};
WiseTrackBridge.Initialize(config);
}
}Note: Replace "your-app-token" with the token provided by the WiseTrack dashboard.
Below are common tasks you can perform with the WiseTrack Unity Package.
Enable or disable tracking at runtime:
// Enable tracking
WiseTrackBridge.SetEnabled(true);
// Disable tracking
WiseTrackBridge.SetEnabled(false);
// Check if tracking is enabled
bool isTrackingEnabled = WiseTrackBridge.IsEnabled();
Debug.Log($"Tracking enabled: {isTrackingEnabled}");Manually control tracking:
// Start tracking
WiseTrackBridge.StartTracking();
// Stop tracking
WiseTrackBridge.StopTracking();To enable WiseTrack Uninstall Detection feature, you need to configure your project to receive push notifications using Firebase Cloud Messaging (FCM).
Follow the official Firebase documentation to set up FCM in your project: 👉 Firebase Cloud Messaging Setup Guide
Once FCM is configured, you need to get Fcm token and pass them to WiseTrack:
FirebaseMessaging.GetTokenAsync().ContinueWithOnMainThread(task => {
if (task.IsCompleted && !task.IsFaulted)
{
string token = task.Result;
WiseTrackBridge.SetFCMToken(token);
}
});
// Or Monitor notification token refresh:
FirebaseMessaging.TokenReceived += OnTokenReceived;
void OnTokenReceived(object sender, TokenReceivedEventArgs token)
{
WiseTrackBridge.SetFCMToken(token.Token);
}And finally inside your FirebaseMessaging.MessageReceived handlers, call the following helper method to check if the message belongs to WiseTrack:
FirebaseMessaging.MessageReceived += OnMessageReceived;
void OnMessageReceived(object sender, MessageReceivedEventArgs e)
{
if (WiseTrackBridge.IsWiseTrackNotificationPayload(e.Message.Data))
{
// This notification is handled internally by WiseTrack.
return;
}
// Otherwise, handle your app's custom notifications here.
}
Log custom or revenue events:
// Log a default event
var Params = new Dictionary<string, WTParamValue>
{
{ "param-1", WTParamValue.FromDynamic("unity") },
{ "param-2", WTParamValue.FromDynamic(2.3) },
{ "param-3", WTParamValue.FromDynamic(true) },
};
WTEvent Event = WTEvent.DefaultEvent("default-event", Params);
WiseTrackBridge.LogEvent(Event);
// Log a revenue event
WTEvent Event = WTEvent.RevenueEvent("revenue-event", WTRevenueCurrency.IRR, 120000, Params);
WiseTrackBridge.LogEvent(Event);Note: Event parameter keys and values have a maximum limit of 50 characters.
Control the verbosity of SDK logs:
WiseTrackBridge.SetLogLevel(WTLogLevel.Debug); // Options: None, Error, Warning, Info, DebugRetrieve the Advertising ID (Ad ID) on Android:
// Get Ad ID (Android)
string adId = WiseTrackBridge.GetAdId();
Debug.Log($"Ad ID: {(string.IsNullOrEmpty(adId) ? "Not available" : adId)}");Customize the SDK behavior through the WTInitialConfig parameters:
AppToken: Your unique app token (required).UserEnvironment: The environment (Production,Sandbox).AndroidStore: The Android app store (e.g.,PlayStore,CafeBazaar,Myket,Other).TrackingWaitingTime: Delay before starting tracking (in seconds).StartTrackerAutomatically: Whether to start tracking automatically.CustomDeviceId: A custom device identifier.DefaultTracker: A default tracker for event attribution.LogLevel: Set the initial log level.OaidEnabled: Indicates whether the Open Advertising ID (OAID) is enabled.ReferrerEnabled: Indicates whether the Referrer ID is enabled.
Example with advanced configuration:
var config = new WTInitialConfig
{
AppToken = "your-app-token",
UserEnvironment = WTUserEnvironment.Sandbox,
AndroidStore = WTAndroidStore.PlayStore,
TrackingWaitingTime = 3,
StartTrackerAutomatically = true,
CustomDeviceId = "custom-device-123",
DefaultTracker = "default-tracker",
LogLevel = WTLogLevel.Debug,
OaidEnabled = false,
ReferrerEnabled = true
};
WiseTrackBridge.Init(config);A Sample project demonstrating the WiseTrack Unity Package integration is available at Samples~ Folder.
- SDK not initializing: Ensure the
AppTokenis correct and the network is reachable. - Logs not appearing: Set the log level to
WTLogLevel.Debugand check Console Logs. - Ad ID not available: Ensure Google Play Services is included and the
play-services-ads-identifierdependency is added (Android). - Dependency conflicts: Use EDM4U to resolve conflicts (
Assets > External Dependency Manager > Android Resolver > Resolve). If issues persist withappsetorads-identifier, try the WiseTrackIdentifier Unity Package.
For further assistance, contact support at support@wisetrack.io.
The WiseTrack Unity Package is licensed under the WiseTrack SDK License Agreement. See the LICENSE file for details.