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
// Checking the status of the boolean variable. It shows the user confirmation. if (flag) { // Enabling sending statistics. YandexMetrica.setStatisticsSending(getApplicationContext(), true); }
Copied to clipboard
To initialize a library with statistics sending option disabled, set the value NO
for the statisticsSending property of the YMMYandexMetricaConfiguration configuration.
// Creating an extended library configuration. YMMYandexMetricaConfiguration *configuration = [[YMMYandexMetricaConfiguration alloc] initWithApiKey:@"API_key"]; // Disabling sending statistics. configuration.statisticsSending = NO; // Initializing the AppMetrica SDK. [YMMYandexMetrica activateWithConfiguration:configuration];
Copied to clipboard
// Checking the status of the boolean variable. It shows the user confirmation. if (flag) { // Enabling sending statistics. [YMMYandexMetrica setStatisticsSending:YES]; }
Copied to clipboard
To initialize a library with statistics sending option disabled, set the value NO
for the statisticsSending property of the YMMYandexMetricaConfiguration configuration.
// Creating an extended library configuration. let configuration = YMMYandexMetricaConfiguration.init(apiKey: "API key") // Disabling sending statistics. configuration?.statisticsSending = false // Initializing the AppMetrica SDK. YMMYandexMetrica.activate(with: configuration!)
Copied to clipboard
// Checking the status of the boolean variable. It shows the user confirmation. if flag { // Enabling sending statistics. YMMYandexMetrica.setStatisticsSending(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.