You can find a sample application for implementing Metrix web SDK here.

Initial Configuration

1. Download Metrix library Javascript file from this link and add it to your project.

2. Initialize Metrix at the start of your application by calling the following method:

import metrix from '<path-to-metrix.js>'

var _metrix = metrix.initialize({
	appId: 'zozazzcrpzaptaa',
	uniqueDeviceId: 'fe3343ff444r4'

appId: Your application identifier. You can find this id in your Metrix dashboard under application settings.

uniqueDeviceId: A device identifier which should be Google Advertising Id for Android and Identifier for Advertisers for iOS devices. (Optional)

Note: Unless you are using Trusted Web Activity to open your web application, in order for us to be able to attribute your installations to your advertising campaigns with maximum precision, you must provide this field.

Additional Features


In Metrix, a session is a specific timeframe during which the user interacts with the application. These sessions and the data related to them are captured by the Metrix SDK and provided to you in your dashboard.

Session Identifier

For each session, our SDK generates a unique identifier. You can obtain this identifier String by setting the following listener:

_metrix.setSessionIdListener(metrixSessionId => {


Each interaction that the user has with your application can be introduced as an event in your dashboard and application in order for Metrix to collect and present its statistics.

There are two types of events in Metrix:

  • Custom: Depending on your application logic and the interaction that the user has with your app, you can create and send custom events.
  • Revenue: A special type of custom events you can specify for tracking your application revenue.

Custom Events

You can use Metrix to track any events in your application. Suppose you want to track every tap on a button. You would have to create a new event in the Events Management section of your dashboard and retrieve the generated slug for the event. The slug is to be used in the application code to send the event to Metrix library. So In your button's onClick method you could then invoke the Metrix sendEvent method providing the event slug and optionally some attributes related to the event like the following:

// Send a simple event

// Send an event with attributes
var attributes = {};
attributes['first_name'] = 'Ali';
attributes['last_name'] = 'Bagheri';
attributes['manufacturer'] = 'Nike';
attributes['product_name'] = 'shirt';
attributes['type'] = 'sport';
attributes['size'] = 'large';

_metrix.sendEvent('my_event_slug', attributes);

The parameters for the sendEvent method are as follows:

  • First parameter: The event slug which is a String you receive from the Metrix dashboard.
  • Second parameter (optional): A Map<string, string> that specifies the attributes of an event.

Specify the Default Attributes for a User

Using the following method, you can add arbitrary attributes to all events of the user:

var attributes = {};
attributes['manufacturer'] = 'Nike';



If your users can generate revenue by tapping on advertisements or making in-app purchases, you can track those revenues with a special type of Metrix custom event. This is specially useful for tracking in-app purchases. Like any custom event, revenues must be defined in dashboard event management section to retrieve the slug. You can see an example below where a tap is worth 12,000 IRR:

_metrix.sendRevenue('my_event_slug', 12000, 'IRR', 'order id');
  • The first parameter is the slug you get from the dashboard.
  • The second parameter is the amount of revenue.
  • The third parameter is the currency of this event which can be IRR (Default), USD, or EUR.
  • The fourth parameter is your order identifier (optional).

Device Identifier

For each device with your app installed on, our service generates a unique identifier. You can obtain this identifier by introducing a listener using the following method:

_metrix.setUserIdListener(metrixUserId => {