Set a user ID
This page covers every SDK platform and version. A part that applies only to some platforms starts with Platform: …, and a part that applies only to some SDK versions starts with SDK version: ….
If your app already assigns a unique ID to each user, you can share this ID with the justtrack SDK. This allows the justtrack backend to associate events received from third parties with the correct user.
If a user’s ID changes, you must provide the new value to the justtrack SDK:
- Android
- iOS
- Unity
- React Native
- Flutter
- Godot
- Unreal
Platform: Android
val userId: String = // get your custom user ID from your app
// Use the builder to set a custom user ID
val sdk = JustTrackSdkBuilder(this, API_TOKEN)
.setUserId(userId)
// other options...
.build()
// Or use an existing JustTrackSdk instance to update the custom user ID
sdk.setUserId(userId)
Platform: iOS
var userId = /* get your user ID from your app */
// set userId using builder
let sdk = JustTrackSdkBuilder(apiToken: API_TOKEN)
.set(userId: userId)
// other options...
.build()
// or using JustTrackSdk instance
sdk.set(userId: userId)
Platform: Unity
using JustTrack;
string customUserId = /* get your own user ID from your game */;
JustTrackSDK.SetUserId(customUserId);
Platform: React Native
await new JustTrackSdk.JusttrackSdkBuilder(apiKey)
.withUserId('new_id')
.initialize();
// new user ID for some reason
await JustTrackSdk.setUserId('new_id');
Platform: Flutter
// Set userId during initialization
await JustTrackSdk.initialize(
apiToken: apiToken,
userId: 'your-custom-user-id',
);
Platform: Godot
# Pass user_id as the fourth argument to initialize()
JustTrackSdk.initialize(api_token, false, false, "your-custom-user-id")
Platform: Unreal
UJustTrackSubsystem* JustTrack = GetGameInstance()->GetSubsystem<UJustTrackSubsystem>();
FJustTrackVoidResult OnComplete;
OnComplete.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(AMyActor, HandleUserIdSet));
JustTrack->SetUserId(TEXT("your-custom-user-id"), OnComplete);
SetUserId() is also a Blueprint node. Add Set User Id from the justtrack category, connect the subsystem from Get justtrack, and drag from On Complete to add a custom event if you want to handle the result. The event gives you a Success boolean and an Error struct with Code and Message pins.
If you already know the ID before initialization, put it in your configuration instead, so the first events carry it:
FJustTrackConfig Config;
Config.ApiToken = TEXT("...paste your API token here");
Config.UserId = TEXT("your-custom-user-id");
In a Blueprint graph, fill the User Id pin on Make JustTrackConfig. This needs Configure at Runtime, which is the default. The Project Settings page has no user ID field, so if you configure the SDK there, call SetUserId() after initialization instead.
The user ID must be shorter than 4096 characters and only consist of printable ASCII characters (U+0020 to U+007E).