Methods reference

In the code, use window.appMetrica for accessing AppMetrica.

  1. activate
  2. reportEvent
  3. reportError
  4. setLocation
  5. setLocationTracking

activate

Activates the AppMetrica plugin with the given configuration.

activate(config)

Parameters

Parameter Default value Description
config*

Тип: Object

Plugin configuration

config.apiKey*

Тип: String

A unique application identifier that is issued in the AppMetrica web interface during app registration.

config.handleFirstActivationAsUpdate false

Тип: Boolean

A flag that indicates whether the first launch of an app with the AppMetrica Plugin is an app update (not an installation)
Attention. If the first launch of the app is defined as an update, the installation is not shown as a new installation in reports, and is not attributed to partners.
config.locationTracking true

Тип: Boolean

A flag that indicates whether the automatic locating detection is enabled

config.sessionTimeout 10

Тип: Number

Session timeout (in seconds)

config.crashReporting true

Тип: Boolean

A flag that indicates whether crash monitoring is enabled

config.appVersion null

Тип: String

App version

config.logs false

Тип: Boolean

A flag that indicates whether the logging is enabled

config.location null

Тип: Object

Custom device location data in the specific format

config.preloadInfo null

Тип: Object

Data for tracking pre-installed apps

config.preloadInfo.trackingId*

Тип: Object

The tracker ID.

config.preloadInfo.additionalParams

Тип: Object

Additional information for tracking pre-installed apps. Specified as a key-value pair

* Обязательный параметр/опция.

reportEvent

Sends a custom event message.

reportEvent(eventName[, params])

Parameters

Параметр Значение по умолчанию Описание
eventName*

Тип: String

Short name or description of the event

params

Тип: Object

The JavaScript object as key-value pairs to be sent to the server

* Обязательный параметр/опция.

reportError

Sends a custom error message.

reportError(errorName[, reason])

Parameters

Параметр Значение по умолчанию Описание
errorName*

Тип: String

Short name or description of the error

reason

Тип: String

Reason of the error

* Обязательный параметр/опция.

setLocation

Sets a custom location value.

setLocation(location)

Parameters

Параметр Значение по умолчанию Описание
location*

Тип: Object

Device location data

location.latitude*

Тип: Number

Latitude in degrees

location.longitude*

Тип: Number

Longitude in degrees

location.altitude

Тип: Number

Altitude in degrees

location.accuracy

Тип: Number

Horizontal accuracy in meters

location.verticalAccuracy

Тип: Number

Vertical accuracy in meters

location.course

Тип: Number

Movement course in degrees

location.speed

Тип: Number

Movement speed in km/h

location.timestamp

Тип: Number

Unix format timestamp of location

* Обязательный параметр/опция.

setLocationTracking

Enables or disables automatic location detection.

setLocationTracking(enabled)

Parameters

Параметр Значение по умолчанию Описание
enabled*

Тип: Boolean

A flag that indicates whether the automatic locating detection is enabled

* Обязательный параметр/опция.