How Yandex.Metrica works

Using Yandex.Metrica begins with creating a counter, which is a code snippet to insert in webpage contents. When a counter is generated, Yandex.Metrica also creates a data store associated with it.

Users interact with the webpages of a site where the counter is installed. The counter code runs and transmits data to the Yandex.Metrica service about the page itself and about events that occurred when a user interacted with it.

Collecting and transmitting data

The counter code consists of two parts: JavaScript code in the script element, and HTML code in the noscript element.

If the page is loaded by a browser, the standard behavior is as follows. If the browser supports execution of JavaScript code and execution is not blocked by browser settings or add-ons, the JavaScript code in the script element runs. Otherwise, the content of the noscript element is processed.

If the page is loaded by something other than a browser (for instance, by a robot), any interpretation of the counter code is possible.

When the counter's JavaScript code isn't executed, only a limited amount of information can be collected. The Yandex.Metrica server extracts session information from HTTP request headers to download the image. The link to the image is inside the noscript element. The information that can be extracted from HTTP request headers includes the user's IP address, the URL of the page containing the image, browser and OS information, cookie data, and the absence of JavaScript support (based on the noscript element).

When the counter's JavaScript code is executed, much more information is available. The JavaScript code has access to information about the HTML page title, the URL of the traffic source, parameters of the screen and the browser window, browser plug-ins and extensions (Java, Silverlight, Flash), and so on. In many cases it is most significant that the JavaScript code can track events that occur while the user is interacting with the page. This includes filling in and submitting forms, clicking links, and scrolling. In addition, the JavaScript code measures page loading parameters (such as rendering time) and can transmit data about goals completed.

You may notice that Yandex.Metrica allows you to get more information about users and their interaction with the site pages than the counter itself can collect. For example, the browser doesn't have information about the user's gender, age, or locality. This information is detected by the service. Significant computing resources and large volumes of data are often used for this purpose.

The data collected by the counter is processed on Yandex.Metrica servers and supplemented with various information.

Processing and storing data

The collected data is processed by the service. Statistical objects are formed in the counter's storage based on this data.

Yandex.Metrica works with multiple data levels and uses the following types of statistical objects:

Object Level


page load

file download

external link

Basic level
Session Second level
User Third level

A statistical object is defined by a set of attributes.

Some of the attributes are shared by all types of statistical objects. For example, any type of object can have the operating system and user's country defined, if this information was detected.

Some attributes are specific to certain types of statistical objects. For example, a defining pageview attribute is the page URL of the click-through (referer), a session attribute is the session length, and a user attribute is the date of the user's first session.

These levels can be represented in a diagram:

You can transmit additional parameters to Yandex.Metrica while users are interacting with the site. However, it is important to differentiate between session or pageview parameters and user parameters. User parameters differ from session or pageview parameters in that they aren't tied to a specific time of the site session.

For example, the “send feedback” event belongs to a specific session, because the user could only submit the feedback once over the entire history of sessions. There isn't any point in making this event a user attribute, because the reports would make it look like this user submitted the same feedback once during every session.

To compare the behavior of users who have left feedback at least once with those who have never sent feedback, you need to configure sending this event via session parameters, and then create the appropriate segments. The user parameters should only transmit attributes that don't change from session to session, and that don't contain users' personal information. For instance, you can transmit the type of client — “retail” or “wholesale”.

Receiving and displaying data. Metrics

Each object is defined by the start time of the corresponding event (or sequence of events).

So we can select statistical objects of a specific type within a certain time period. Then we can use attribute values to calculate a variety of absolute or average numbers. These numbers are called metrics. Examples are the overall page depth, or the number of sessions with a depth greater than 5.

Metrics are always calculated for the same type of statistical objects.

A typical task when analyzing metrics is to determine how much one of the groups contributes to the total. For example, you may want to find out how many of a site's users are men, and how many are women. In Yandex.Metrica, you can define groups of objects using conditions placed on attribute values, and calculate the metric values for each group. This process of breaking up a total into its parts is called dimensions.

Often you don't need all the objects, but just those that match the specified criteria. For example, you want to analyze the behavior of users who click through from ads. Yandex.Metrica lets you form a sample of desired objects using conditions placed on attribute values. This process is called segmentation, and the selected set of objects is a segment.

Segmentation and dimensions can be used together. For example, you can select a segment of sessions that came from search engines, and group the sessions by keyword.

For viewing and analyzing metrics, reports and widgets are used. For studying user behavior, Session Replay, maps, and the form analysis service are available.