Enabling the AppMetrica SDK

Before using the plugin, install it in Android Studio by following the instructions.

Step 1. Open the dialog box for enabling the AppMetrica SDK

In the main menu, choose Tools → AppMetrica → Integrate.

Note.
  1. If your project doesn't have any Android apps, the AppMetrica menu is inactive.
  2. For the AppMetrica menu to be active, your project must be synchronized.

Step 2. (Optional) Choose the app to enable the AppMetrica SDK for.

Note. If there is only one Android app in your project, you won't be able to choose an app. Just skip this step.

If your project has several Android apps, choose the one to enable the AppMetrica SDK for.

If you want to enable the AppMetrica SDK for multiple apps, repeat these steps for each one.

Step 3. Specify the app's API key

Open the app settings in the AppMetrica web interface and copy the value from the API key (for SDK) field.

Step 4. (Optional) Enable or disable additional SDK settings

Available settings:

First activation as update

If your app already has users, AppMetrica will count them as new users by default. To avoid counting the current audience as new, turn on the firstActivationAsUpdate flag and specify under which conditions users will be counted as old.

For more information, see Tracking new users.

Location tracking

With this setting, AppMetrica will automatically detect the device location and send this information to reports and the Logs API.

For more information, see Determining the location on Android.

Logs

Enables logging the activity of the AppMetrica library We don't recommend enabling this flag for the test version of the app.

Statistic sending

Enables/disables sending statistics to the AppMetrica server. For example, if the user's consent is required to send statistical data.

To enable sending statistics later, use the YandexMetrica.setStatisticsSending(Context context, boolean enabled) method.

For more information, see Disabling and enabling sending statistics.

Step 5. (Optional) Copy the configured events for AppsFlyer

Note. If AppsFlyer is not enabled in your app, the option isn't shown. Just skip this step.

If your project has event tracking configured for the AppsFlyer service, you can create similar events for AppMetrica. To do this, turn on Copy events from AppsFlyer.

Note. When adding new events for AppsFlyer, use Copying events from AppsFlyer to send new events to AppMetrica.

Step 6. Enable the AppMetrica SDK

Click Ok.

As a result of the plugin's operation, the gradle dependency on the AppMetrica SDK and its activation will be added to the application code. Also, if you turned on the Copy events from AppsFlyer option, a method for sending events to AppMetrica will be added next to each event sending method to AppsFlyer.

Step 7. (Optional) Add the code to identify new users

If you enabled the First activation as update option (your application already has users), then the isFirstActivationAsUpdate method will be added in your class inherited from Application.

For more information, see Tracking new users.

Step 8. Test AppMetrica

To test how the library works:

  1. Start the app with the AppMetrica SDK and use it for a while.

  2. Make sure your device is connected to the internet.

In the AppMetrica interface, make sure that:

  1. There is a new user in the Audience report.

  2. The number of sessions in the Engagement → Sessions report has increased.

  3. There are events and profile attributes in the Events and Profiles reports.

If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.