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
.- If your project doesn't have any Android apps, the AppMetrica menu is inactive.
- For the AppMetrica menu to be active, your project must be synchronized.
Step 2. (Optional) Choose the app to enable the AppMetrica SDK for.
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
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.
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:
Start the app with the AppMetrica SDK and use it for a while.
Make sure your device is connected to the internet.
In the AppMetrica interface, make sure that:
There is a new user in the Audience report.
The number of sessions in the
report has increased.There are events and profile attributes in the Events and Profiles reports.