Skip to main content

Get device information

The Adtrace SDK includes helper methods that return device identifiers. Use these IDs in callbacks, server-side integrations, or S2S events.

MethodReturnsTypical 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 IDAmazon / 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.

Important

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

String adid = AdTrace.getAdid();

Google Play Services advertising ID

Method signature

public static void getGoogleAdId(Context context, OnDeviceIdsRead onDeviceIdRead)
ParameterTypeDescription
contextContextThe Android context (for example your Activity or Application).
onDeviceIdReadOnDeviceIdsReadCallback 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.

Important

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

AdTrace.getGoogleAdId(this, new OnDeviceIdsRead() {
@Override
public void onGoogleAdIdRead(String googleAdId) {
// ...
}
});

Amazon Advertising ID

Method signature

public static String getAmazonAdId(final Context context)
ParameterTypeDescription
contextContextThe 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

String amazonAdId = AdTrace.getAmazonAdId(getApplicationContext());