Installation and initialization

AppMetrica Cordova is a plugin for the Cordova (PhoneGap) platform. It includes support for the AppMetrica SDK for Android and iOS via the Javascript interface.

Step 1. Integrate the AppMetrica Cordova plugin

  1. Add the plugin to the project by using one of the following console commands:
    cordova plugin add yandex-appmetrica-plugin-cordova
    Copied to clipboard


    cordova plugin add
    Copied to clipboard

    When you add another supported platform to the project, the plugin automatically downloads the corresponding SDK library.

Step 2. Initialize the library

An example of initializing the library:

document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
    // Creating an extended library configuration.
    var configuration = {
        // Mandatory.
        apiKey: 'Your API key',
        // Optional.
        locationTracking: true,
        handleFirstActivationAsUpdate: true,
        sessionTimeout: 15
    // Initializing the AppMetrica SDK.
    // Sending a custom event.
    window.appMetrica.reportEvent('Test event', { 'foo': 'bar' });
Copied to clipboard
What is the API key?

The API key is a unique application identifier that is issued in the AppMetrica web interface during app registration.

Make sure you have entered it correctly.

Example of a project with the integrated AppMetrica SDK on GitHub.