Getting advertising IDs

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.

  1. Integrating a library for getting advertising IDs
  2. Setting up permissions to use advertising IDs

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.

Note.

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.permissio