Chapter 1 — Anatomy of Metrics

What exactly are we counting

14 min
What you'll learn
  • read an event log: what a single event row is made of
  • tell apart four counting units on the very same data: event, user, visit, order
  • assemble a metric definition from four parts: object → event → period → counting method
  • understand why two analysts compute "the same" metric and get different numbers

Before you count — look at what is in the box

"You are about to count users. Not so fast. First answer this: what in this archive even is a user?" — QUERY

A cadet examines a hologram in which the same events are grouped as individual actions, users, visits, and orders while the robot-cat watches from the side.
Until you name what is being counted — event, user, visit or order — the number means nothing: the same data yields four different ones.

Kotomarket's black box is not a "users" table and not a "metrics" table. It is an event log: a long list of rows, each meaning "this happened at this moment".

Here are nine rows from a single day — March 14:

timeuser_idsession_ideventproperties
09:12:044412s-101app_opensource=push
09:12:314412s-101product_viewitem=bowl
09:13:024412s-101product_viewitem=scratcher
09:13:404412s-101add_to_cartitem=scratcher
09:20:117781s-102app_opensource=direct
09:21:557781s-102product_viewitem=cat bed
14:02:094412s-140app_opensource=direct
14:03:444412s-140purchasesum=1290
21:47:009003s-166app_opensource=ads

Every column answers its own question:

  • time — when it happened. Periods are built from it: day, week, month;
  • user_id — who. The same cat carries the same id across all their visits;
  • session_id — which visit it belongs to. A new visit after a long pause gets a new session id;
  • event — what the person actually did;
  • properties — the details of that particular action: which source they came from, which item they viewed, how much they paid.

The key thing to absorb right now: metrics are not stored in the black box. Only events are. A metric is an instruction for folding the log into a single number. The analyst writes that instruction — and the number changes with how it is written.

An event is one line of the log4412product_view19:00:12812|||whouser_idwhentimestampwhat they dideventwith which objectproduct_idevent = who · what · when · with which object
Anatomy of an event: who, when, what they did and within which visit. Every metric in this chapter is assembled from those four answers.

The same data — four different answers

Take those same nine rows and ask four simple questions.

How many events? Nine — one per row. The most mechanical number there is: how many records landed in the log.

How many users? Three — 4412, 7781 and 9003. Cat 4412 left six traces, but he is one cat. Here we drop duplicates by user_id.

How many visits (sessions)? Four — s-101, s-102, s-140, s-166. Cat 4412 came twice: in the morning and in the afternoon.

How many orders? One — the single purchase event.

9 events → 4 visits → 3 users → 1 order

Nine, four, three, one. The data did not change — the counting unit did. And none of the four numbers is "more correct" than the others: they answer different questions.

Hence the first professional habit: when you hear a number, ask what unit is underneath it. "We have forty thousand" — forty thousand what: events, people, visits, purchases? At Kotomarket the gap between the extreme units is nearly tenfold, and in a report they all look equally solid.

Entry #2 in L.'s journal:

"For six months the board was shown 'activity' counted in events and compared with the customer count from billing. Nobody noticed they were dividing apples by kilometres. The 'events per customer' ratio was growing — engagement was celebrated. It turned out that for some people the app was restarting itself."

It also helps to keep the ordering in mind: there are always at least as many events as visits, and at least as many visits as people. If a report shows more "users" than "events", that is not a record — that is a broken count.

A metric definition has four parts

A metric is not a name. The name is the label on the jar; the definition is what is inside. A complete definition answers four questions:

  1. Object — what do we count one by one: users, sessions, orders, events?
  2. Event — what has to happen for the object to be counted: opened the app, viewed a product, paid?
  3. Period — over which time window: a calendar day (in which timezone?), a calendar week, the last 7 days?
  4. Counting method — do we count unique objects or every match? Do we sum, average, take a share?

Here is a complete definition worth getting used to:

DAU = the number of unique user_ids (object) that have at least one app_open event (event) during a calendar day in Moscow time (period), each user counted once (counting method).

Long-winded? Yes. But with a definition like that, two different people get the same number — and that is the whole point.

Uniques versus event counts

The most common substitution lives in part four. Compare two phrasings on the same day:

phrasingMarch 14
number of app_open events18,400
number of unique users with app_open4,200

Both numbers are honest, both come from the same log, and they differ by 4.4x. But they behave differently: if a bug makes the app restart itself, the first number grows and the second does not. The first measures activity, the second measures people.

Rule of thumb: the moment you hear "how many users do we have", mentally add the word unique — then check that it is actually there.

Why two analysts get different numbers

Entry #5 in L.'s journal. A manager asks two analysts for "the number of active users in March". Two answers come back: 41,200 and 33,900. Both counted honestly, neither made an arithmetic mistake. Here is where they diverged:

part of the definitionfirst analystsecond analyst
objectunique user_idsunique user_ids
eventany event in the logonly app_open
periodMarch 1–31the last 30 days as of March 31
counting methoduniqueunique

The gap is 7,300 people — 18%. Arguing about who is right is pointless: both are. It was the question that was incomplete.

Notice exactly where it split: rows two and three. The first analyst counted anyone who left any trace at all — including people who merely received a push and had its delivery recorded. The second demanded a deliberate app open. Plus different windows: 31 calendar days versus 30 consecutive days ending today.

The classic beginner mistake is treating the definition as "obvious" and being shy about clarifying it. In practice the question "active — meaning who exactly, over which window?" sounds like professionalism, not ignorance. Ignorance is quietly counting by your own definition and shipping the number unsigned.

The investigator's practical rule, useful for the rest of this course:

Before you count, write the definition in one sentence — object, event, period, method — and show it to whoever asked. Five minutes of agreement save a day of rework and spare you a conclusion built on someone else's arithmetic.

And if the number goes into a report, let the definition travel with it as a footnote. In a month you will not remember what you meant either.

The investigator's calculator. In this chapter the runner is exactly that: variables, arithmetic and print. Below are the March 14 log totals counted in four different units. Run it, then change the numbers and watch the ratios move.
python · pandas
Practice: write the code
The same March 14 totals are already in variables. Compute the two ratios an analyst checks first: events per user (events_per_user) and visits per user (sessions_per_user). Both are plain division — no rounding needed.
python · pandas
Practice: write the code
The March 14 report says: "buyers — 1,284". In fact 1,284 is the number of purchase events, and there are 1,050 unique user_ids among them. Compute by how many people the report overstated the buyer count (overcount) and how many orders one buyer places (orders_per_buyer).
python · pandas
Check yourself
Nine rows in a day's log: cat 4412 left 6 events across two sessions, cat 7781 left 2 events in one session, cat 9003 left 1 event in one session. How many "users" and how many "visits" are there?
Check yourself
A stakeholder asks: "count the weekly active users". Which question should you ask FIRST so the number does not need recomputing later?
Key takeaways
  • the black box stores events, not metrics; a metric is an instruction for folding the log into a number
  • the same rows yield four different numbers: events, visits, users, orders — always ask which unit is underneath
  • a metric definition has four parts: object → event → period → counting method
  • "uniques" and "event counts" are different metrics; the gap can be several-fold
  • if the definition is not fixed, two honest analysts will legitimately get different numbers

Next — the first real metric: DAU. We will assemble it from those four parts and see how the single word "active" yields three different answers.