Get device information
The Adtrace SDK includes helper methods that return device identifiers. Use these IDs in callbacks, server-side integrations, or S2S events.
| Method | Returns | Typical use |
|---|---|---|
getAdid() | Adtrace device ID (adid) | S2S when gps_adid is unavailable, internal device mapping |
getGoogleAdId() | Google Play Services advertising ID (gps_adid) | Google Play devices, S2S, callback placeholders |
getAmazonAdId() | Amazon Advertising ID | Amazon / Fire OS devices |
Adtrace device identifier
Method signature
public static String getAdid()
Adtrace generates a unique Adtrace device ID (adid) for each device. Call getAdid to return this ID as a String.
The adid is only available after Adtrace tracks the app install. You cannot read it before the SDK is initialized and the install has been successfully tracked.
Example
- Java
- Kotlin
- Javascript
String adid = AdTrace.getAdid();
val adid = AdTrace.getAdid()
let adid = AdTrace.getAdid();
Google Play Services advertising ID
Method signature
public static void getGoogleAdId(Context context, OnDeviceIdsRead onDeviceIdRead)
| Parameter | Type | Description |
|---|---|---|
context | Context | The Android context (for example your Activity or Application). |
onDeviceIdRead | OnDeviceIdsRead | Callback that receives the Google advertising ID. |
The Google Play Services Advertising ID (GPS ADID) is a device-specific identifier on Android.
Users can opt out of sharing their GPS ADID with Opt out of Ads Personalization. When that setting is enabled, the SDK returns a string of zeros when you try to read the GPS ADID.
If you target Android 12 (API level 31) or higher, add the com.google.android.gms.AD_ID permission to your app. Without it, you cannot read the Google advertising ID even if the user has not opted out.
Read the GPS ADID with getGoogleAdId. The SDK reads it on a background thread and returns the value through your callback. Some services (such as Google Analytics) need this ID coordinated with client IDs to avoid duplicate reporting.
Example
- Java
- Kotlin
- Javascript
AdTrace.getGoogleAdId(this, new OnDeviceIdsRead() {
@Override
public void onGoogleAdIdRead(String googleAdId) {
// ...
}
});
AdTrace.getGoogleAdId(this, object : OnDeviceIdsRead {
override fun onGoogleAdIdRead(googleAdId: String) {
// ...
}
})
AdTrace.getGoogleAdId(function (googleAdId) {
// ...
});
Amazon Advertising ID
Method signature
public static String getAmazonAdId(final Context context)
| Parameter | Type | Description |
|---|---|---|
context | Context | The Android context your app runs in. Prefer getApplicationContext() / applicationContext. |
The Amazon Advertising ID (Amazon Ad ID) is a device-specific identifier on Amazon / Fire OS Android devices. Call getAmazonAdId to return this ID as a String.
Use this on Amazon Appstore builds. On Google Play devices, use getGoogleAdId instead.
Example
- Java
- Kotlin
- Javascript
String amazonAdId = AdTrace.getAmazonAdId(getApplicationContext());
val amazonAdId = AdTrace.getAmazonAdId(applicationContext)
let amazonAdId = AdTrace.getAmazonAdId();