Installation and initialization

Attention.

Support and development of the plugin has been stopped. We do not guarantee the SDK will work correctly.

  1. Step 1. Integrate the AppMetrica Cordova plugin
  2. Step 2. Initialize the library
  3. Step 3. (Android) Connect the Play Install Referrer library

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

    or

    cordova plugin add https://github.com/yandexmobile/metrica-plugin-cordova.git
    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.
    window.appMetrica.activate(configuration);
    // 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.