Lesson 3: How Yandex.Metrica works
In the previous lesson, you learned about three basic concepts in web analytics: pageviews, sessions, and users. Now let’s look at how Yandex.Metrica collects and processes data about sessions and builds reports. Understanding the underlying principles of Yandex.Metrica will give you the confidence to optimize how you use it.
Let’s see what happens between the user’s click on the link and session display in Yandex.Metrica reports.
First of all, the user lands on your website from a search engine, link on another site, ad banner, or some other way. The HTML code of your website page loads into the user’s browser at this point. If Yandex.Metrica is installed on the website, the code of the Yandex.Metrica tag is embedded in the webpage code. This code is going to send data about user actions to Yandex.Metrica servers. The first thing sent is a page load notification. It contains lots of additional parameters: the user’s source page address (this tells Yandex.Metrica where the user came from), the name and version of their browser and operating system, screen resolution, and other data.
But that’s not all the Yandex.Metrica code does. During pageview, it sends more data: if in 15 seconds the user doesn’t close the page or move to another page, the code reports that the pageview is still in progress. Moreover, the code reports any target actions performed by the user, like placing an order. The Yandex.Metrica code can also report page scrolls and all mouse movements on the page.
All the events contain a unique user ID (i.e., their browser instance). This helps Yandex.Metrica collect the chains of events from a user and combine them into sessions. When all the session data is collected, Yandex.Metrica saves it in a dedicated ClickHouse database. The database uses sessions and their data as the main data units.
When you open Yandex.Metrica and select a report, the data for the report is retrieved from the ClickHouse database. To begin with, Yandex.Metrica selects only the website sessions that occurred in the reporting period. Then you can filter the sessions based on criteria: for example, you can limit your analysis to users who landed from social media.
Focusing your analysis on some part of your website audience is called segmentation, and we’ll look at this in detail in the next course.
Then the selected visits are grouped by your parameter: for example, by the source address. Finally, your focus indicators (metrics) are calculated for each group, for example: session count, unique users count, or average pageview time. The reports can even show user sessions from a few minutes ago.
The resulting data is output to a Yandex.Metrica report table. Each table row corresponds to one session group. For each group, preset metrics are shown. You can use various types of charts to display the table data and see how any metric changes over time.