Device IDs
The Adtrace SDK offers you the possibility to obtain device identifiers.
Google Play Services Advertising Identifier (GPS AdId)
If you are targeting Android 12 (API level 31), and above you need to add the com.google.android.gms.AD_ID permission to your app.
If you do not add this permission, you will not be able to read the Google advertising ID even if the user has not opted out of sharing their ID.
Certain services (such as Google Analytics) require you to coordinate advertising IDs and client IDs in order to prevent duplicate reporting.
- Java
- Javascript
If you need to obtain the Google Advertising ID, there is a restriction; it can only be read in a background
thread. If you call the function getGoogleAdId with the context and a OnDeviceIdsRead instance, it will
work in any situation:
AdTrace.getGoogleAdId(this, new OnDeviceIdsRead() {
@Override
public void onGoogleAdIdRead(String googleAdId) {
//...
}
});
To obtain the device's Google Advertising device identifier, it's necessary to pass a callback function to
AdTrace.getGoogleAdId which will receive the Google Advertising ID in its argument, like so:
AdTrace.getGoogleAdId(function (googleAdId) {
// ...
});
Adtrace device identifier
For each device with your app installed on it, our backend generates a unique Adtrace device identifier (known as an adid).
In order to obtain this identifier, call the following method on AdTrace instance:
- Java
- Javascript
String adid = AdTrace.getAdid();
let adid = AdTrace.getAdid();
Information about the adid is only available after our backend tracks the app install. It is not possible to access the adid value before the SDK has been initialized and the installation of your app has been successfully tracked.
External device ID (Experimental)
This feature is not fully integrated to Adtrace panel!
An external device identifier is a custom value that you can assign to a device or user. They can help you to recognize users across sessions and platforms. They can also help you to deduplicate installs by user so that a user isn't counted as multiple new "install"s.
You can also use an external device ID as a custom identifier for a device. This can be useful if you use these identifiers elsewhere and want to keep continuity.
You need to set your external device ID before initializing the Adtrace SDK.
To set an external device ID, assign the identifier to the externalDeviceId property of your config instance.
The external device ID is case-sensitive. If you have imported external device IDs, you need to make sure the
value you pass matches the imported value.
- Java
- Javascript
AdTraceConfig.setExternalDeviceId("YourExternalDeviceId");
AdTraceConfig.setExternalDeviceId('YourExternalDeviceId');