Installation and initialization

AppMetrica Cordova is a plugin for the Cordova (PhoneGap) platform that includes support for the AppMetrica SDK for Android and iOS through the JavaScript interface.

Integrating the AppMetrica Cordova plugin

Step 1. Add the supported platforms to your project

Step 2. 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.

Connection example

In the example below:

  • The JavaScript object with the configuration is created.
  • The plugin with the recently created configuration is activated.
  • The event message is sent.
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
    var configuration = {
        // Mandatory
        apiKey: 'Your API key here',
        // Optional
        locationTracking: true,
        handleFirstActivationAsUpdate: true,
        sessionTimeout: 15
    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.