Get an advertiser and test group ID
Version:
The justtrack SDK can provide the advertiser ID of the user if the user didn't limit ad tracking. Additionally, users are assigned to one of three test groups (1, 2, or 3) based on their advertiser ID. You can retrieve the test group ID from the SDK, implement different logic for a specific group, and compare that group’s performance in the justtrack dashboard.
- Android
- iOS
- Unity
- React Native
val infoFuture: Future<AdvertiserIdInfo> = sdk.advertiserId
val info: AdvertiserIdInfo = infoFuture.get()
val advertiserId: String? = info.advertiserId
val isLimitedAdTracking: Boolean = info.isLimitedAdTracking
log("My advertiser ID is $advertiserId")
log("Ad tracking is limited = $isLimitedAdTracking")
val testGroupIdFuture: Future<Int> = sdk.testGroupId
val testGroupId: Int? = testGroupIdFuture.get()
log("My test group ID is $testGroupId")
sdk.getAdvertiserIdInfo().observe { result in
switch result {
case let .success(info):
let advertiserId: String? = info.advertiserId
let isLimitedAdTracking = info.limitedAdTracking
log("My advertiser ID is \(advertiserId)")
log("Ad tracking is limited = \(isLimitedAdTracking)")
let testGroupId: Int? = sdk.testGroupId
log("My test group ID is \(testGroupId)")
case let .failure(error):
log("error: \(error.localizedDescription)")
}
}
using JustTrack;
JustTrackSDK.GetAdvertiserIdInfo((info) => {
// info.AdvertiserId will contain the advertiser ID (lowercase) or null if it'sn't available
// info.IsLimitedAdTracking tells you if the user opted out of ad tracking (the advertiser ID might be null in that case depending on the Android version)
}, (error) => {
// we failed to retrieve the advertiser ID - this is a different case than the user limiting ad tracking
});
JustTrackSDK.GetTestGroupId((testGroupId) => {
// testGroupId is either 1, 2, 3, or null
// if it's null we couldn't retrieve an advertiser ID or IDFV internally
}, (error) => {
// we failed to determine the test group id. This will happen if retrieving the advertiser ID fails
});
const advertiserInfo: JustTrackSdk.AdvertiserIdInfo = await JustTrackSdk.getAdvertiserIdInfo();
const advertiserId: String | null = advertiserInfo.advertiserId;
const isLimitedAdTracking: boolean = advertiserInfo.isLimitedAdTracking;
console.log('My advertiser ID is '+ advertiserId)
console.log('Ad tracking is limited is '+ isLimitedAdTracking)
const testGroupId: JustTrackSdk.TestGroupId | null = await JustTrackSdk.getTestGroupId();
console.log('My test group ID is '+ testGroupId)
info
For Android, if the user enables debug logging then the testGroupId will be null. Also if the GAID of the phone is deleted then the advertiserId and testGroupId is also null.