Getting advertising IDs
This is an archived version of documentation. You can find the current documentation for all platforms here.
An advertising ID is a unique Google Play service identifier for displaying ads to users who agree to see personalized ads. The user can disable the personalization of ads or reset the ID in settings. In this case, advertising networks won't be able to use it to select relevant ads. The accuracy of traffic attribution will also decrease significantly.
Integrating a library for getting advertising IDs
To get advertising IDs, the AppMetrica SDK uses a separate library: com.yandex.android:mobmetricalib-identifiers. This library contains a dependency on com.google.android.gms:play-services-ads-identifier:18.0.1, which is used to get the GAID. The com.yandex.android:mobmetricalib-identifiers library version must match the com.yandex.android:mobmetricalib library version.
A dependency on the com.yandex.android:mobmetricalib-identifiers library is added by default.
Excluding the library of advertising IDs from the list of dependencies
If you don't want to get advertising IDs (for example, for children's apps), exclude the library by changing the method for connecting com.yandex.android:mobmetricalib in the build.gradle file of the project:
dependencies {
...
implementation ("com.yandex.android:mobmetricalib:$appmetricaVersion") {
exclude group: 'com.yandex.android', module: 'mobmetricalib-identifiers'
}
...
}
Setting up permissions to use advertising IDs
Starting from version 4.1.1, a new permission has been added to the AppMetrica SDK com.google.android.gms.permission.AD_ID
. It is written in the AndroidManifest.xml library file. Therefore, you don't need to additionally specify it in the main manifest of the app. The permission allows you to use an advertising ID to select relevant ads from advertising networks.
If necessary, you can delete the permission. For example, if some policies, like the Families Policy, do not allow the use of an identifier for ad selection.
To prevent the permission from appearing in the main application manifest, add the following line to the AndroidManifest.xml file:
<manifest>
...
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
...
</manifest>
If your app uses a version of AppMetrica SDK lower than 4.1.1 and there are no restrictions on the use of an advertising ID (for example, the Families Policy), add the permission to the main application manifest AndroidManifest.xml:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
The lack of permission and access to the ID can reduce advertising relevance and, as a result, your income.