adjust-icon

Steamworks Unity SDK integration guide

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 starting the integration, ensure you have the following:

  1. Unity Environment: Unity Engine installed on your system (2020.3 LTS or higher recommended).
  2. Steamworks Unity SDK: Integrated and configured SteamManager.
  3. Steam client: Installed with an active user and running during testing.
  4. Newtonsoft.Json Library: Follow the installation guide.

Add the Adjust SDK

  1. Download or clone the Adjust Steamworks SDK.
  2. Drag and drop the provided Adjust folder into your Unity project, e.g. Assets/Plugins/(any path under Assets/ is fine).

Initialize the Adjust SDK

The following arguments are required during initialization:

Arguments

  • appToken (string, required): Your unique Adjust app token, obtainable from the Adjust dashboard.
  • environment (string, required): Specifies the environment, e.g., AdjustConfig.EnvironmentSandbox for testing or AdjustConfig.EnvironmentProduction for 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

Retrieve attribution, 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.");
}
});
}