Documentation

AppMetrica Cordova

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
or
cordova plugin add https://github.com/yandexmobile/metrica-plugin-cordova.git

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

Connection examples

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
[no-highlight[

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

]no-highlight]
', // Optional trackLocationEnabled: true, handleFirstActivationAsUpdateEnabled: true, sessionTimeout: 15 } window.appMetrica.activate(configuration); window.appMetrica.reportEvent('Test event', { 'foo': 'bar' }); }
What is the API key?

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