Notice about collecting statistics

You can notify your app users that statistics will be collected, and initialize the SDK with disabled statistics sending before getting consent. This section describes the steps to disable and enable statistics collection:

To initialize a library with statistics sending option disabled, pass the value false into the withStatisticsSending(boolean value) method when creating an extended library configuration.

// Creating an extended library configuration.
YandexMetricaConfig config = YandexMetricaConfig.newConfigBuilder(API_key)
        // Disabling sending statistics.
        .withStatisticsSending(false)
        .build();
// Initializing the AppMetrica SDK.
YandexMetrica.activate(getApplicationContext(), config);
Copied to clipboard
After the user has confirmed to send statistics (for example, in the application settings or in the agreement on the first start of the app), you should call the YandexMetrica.setStatisticsSending(Context context, boolean enabled) method to enable it:
// Checking the status of the boolean variable. It shows the user confirmation.
if (flag) {
    // Enabling sending statistics.
    YandexMetrica.setStatisticsSending(getApplicationContext(), true);
}
Copied to clipboard

Alert example

You can use any text to inform users of statistics collection. For example:

This app uses AppMetrica (Yandex.Metrica for applications) analytics provided by YANDEX LLC, 16, Leo Tolstoy St., Moscow, 119021, Russia (hereinafter referred to as “Yandex”) as specified in the Terms of Use of the service.

AppMetrica analyzes app usage data, including the device it is running on, the installation source, calculates conversion, collects statistics of your activity for product analytics, ad campaign analysis, and optimization, as well as for troubleshooting. Information collected in this way cannot identify you.

Depersonalized information about your use of this app collected by AppMetrica tools will be transferred to Yandex and stored on Yandex’s server in the EU and the Russian Federation. Yandex will process this information to assess how you use the app, compile reports for us on our app operation, and provide other services.