The Adjust Unity Steamworks SDK enables you to record session, events, and more in your Unity Steam game. You can also check out the example app on GitHub.
Integrate the Adjust SDK
This guide outlines how to integrate, initialize, and use the Adjust module for session and event tracking and obtaining attribution information on the Windows and macOS platforms.
Prerequisites
Before you start, make sure you have the following:
- Unity Environment: Unity Engine installed on your system (2020.3 LTS or later recommended).
- Steamworks Unity SDK: Integrated and configured with SteamManager.
- Steam client: Installed with an active user and running during testing.
- Newtonsoft.Json library: Follow the installation guide.
Add the Adjust SDK
- Download or clone the Adjust Steamworks SDK.
- Drag and drop the provided Adjust folder into your Unity project, for example
Assets/Plugins/(any path underAssets/works).
Initialize the Adjust SDK
The following arguments are required during initialization:
Arguments
appToken(string, required): Your unique Adjust app token, available in the Adjust dashboard.environment(string, required): Specifies the environment, e.g.,AdjustConfig.EnvironmentSandboxfor testing orAdjustConfig.EnvironmentProductionfor production.monoBehaviour(MonoBehaviour, required): A MonoBehaviour instance used for running coroutines.
using UnityEngine;
public class AdjustIntegration : MonoBehaviour{ void Start() { AdjustConfig adjustConfig = new AdjustConfig("your_app_token", AdjustConfig.EnvironmentSandbox, this);
// Adjust SDK initialization Adjust.InitSdk(adjustConfig, response => { if (response != null) { Debug.Log($"Adjust SDK Initialized. Response Code: {response.ResponseCode}, Response: {response.ResponseBody}, JsonResponse: {response.GetSerializedJsonResponse()}"); } else { Debug.LogError("Adjust SDK initialization failed."); } }); }}Record Events
Use AdjustEvent to record in‑game actions. You can attach revenue, currency, callback parameters, and partner parameters.
void TrackEvent(){ // Create an AdjustEvent object with an event token AdjustEvent adjustEvent = new AdjustEvent("34vgg9");
// Add Revenue and Currency adjustEvent.SetRevenue(150, "USD");
// Add custom callback parameters adjustEvent.AddCallbackParameter("foo", "bar");
// Add partner parameters adjustEvent.AddPartnerParameter("john", "doe");
// Track an event Adjust.TrackEvent(adjustEvent, response => { if (response != null) { Debug.Log($"Event Tracking Response: Response Code: {response.ResponseCode}, Response: {response.ResponseBody}, JsonResponse: {response.GetSerializedJsonResponse()}"); } else { Debug.LogError("Event tracking failed or returned no response."); } });}Get attribution information
To retrieve attribution data, use the GetAttribution method. The AdjustAttributionData class contains details about the current attribution status of the device. Any values that aren’t populated for the user are returned as a null value.
void GetAttribution(){ Adjust.GetAttribution(response => { if (response != null) { Debug.Log($"Attribution Response: Response Code: {response.ResponseCode}, Response: {response.ResponseBody}, JsonResponse: {response.GetSerializedJsonResponse()}");
// Extract and log attribution data if (response.AttributionData != null) { Debug.Log($"Tracker Token: {response.AttributionData.TrackerToken}"); Debug.Log($"Tracker Name: {response.AttributionData.TrackerName}"); Debug.Log($"Network: {response.AttributionData.Network}"); Debug.Log($"Campaign: {response.AttributionData.Campaign}"); Debug.Log($"AdGroup: {response.AttributionData.Adgroup}"); Debug.Log($"Creative: {response.AttributionData.Creative}"); Debug.Log($"ClickLabel: {response.AttributionData.ClickLabel}"); } } else { Debug.LogError("GetAttribution failed or returned no response."); } });}Store Type
You can use the Adjust SDK to record information about the store from which an app was installed on a user’s device. Adjust supports a predefined list of store types defined here.
Use AdjustStoreInfo to set store information using the SDK configuration object. The Adjust SDK reads and tracks this data during initialization.
To configure this, follow the instructions below:
AdjustConfig adjustConfig = new AdjustConfig("your_app_token", AdjustConfig.EnvironmentSandbox, this);
var storeInfo = new AdjustStoreInfo("NameOfTheStore");storeInfo.StoreAppId = "AppIdForTheStore";adjustConfig.SetStoreInfo(storeInfo);
// Adjust SDK initializationAdjust.InitSdk(adjustConfig, response =>{ if (response != null) { Debug.Log($"Adjust SDK Initialized. Response Code: {response.ResponseCode}, Response: {response.ResponseBody}, JsonResponse: {response.GetSerializedJsonResponse()}"); } else { Debug.LogError("Adjust SDK initialization failed."); }});