Product analytics 8 min read

Event tracking: what to track and how to name it

A tracking plan for a SaaS product: which events to send first, how to name them so they still make sense in a year, and how to tie them to a person and an account.

David Granzin By David Granzin

Every chart in product analytics is built from events: a named thing a person did, with a timestamp and a few properties. A funnel is a sequence of events. A path is the order they happened in.

Two early habits cause a lot of tracking problems: tracking everything, and naming things as they come up. This guide is the plan to write before the first track() call.

Key takeaways

  • Write the questions first. An event that answers no question is noise.
  • About ten events are enough to answer the first questions about signup, activation and revenue.
  • Name events object_verb in lowercase, past tense. Renaming one later splits its history.
  • Send an event from where the thing happens. Signups and payments happen on the server.
  • Identify the user and the account on every event, so one person is counted once.

Start from questions

A tracking plan is a list of events, and for each one its name, when it fires, where it is sent from and which properties it carries. The way to keep that list short is to write down the questions it has to answer and work backwards.

For a typical SaaS product the first questions are these:

  • Acquisition. Of the people who start signing up, how many finish? Which channel sends the ones who do?
  • Activation. How many new accounts reach the first moment the product is useful, and how long does it take?
  • Retention. Which actions do the accounts that stay perform in their first week?
  • Revenue. How many activated accounts start a paid plan, and which plan?

Each question names the events it needs. "How many finish signing up" needs a start and a finish. "Reach the first useful moment" needs you to decide what that moment is, which is a product decision more than a tracking one.

Ten events to start with

This is a starting plan for a B2B SaaS product. The names come from an analytics product, the one the screenshots in this series show. Swap the middle rows for the actions that matter in yours. The first two and the last three apply almost everywhere.

EventFires whenSent fromProperties
signup_startedThe signup form is openedBrowsermethod
signup_completedThe account exists in your databaseServermethod
workspace_createdThe first workspace or project is createdServertemplate
onboarding_connectedThe product receives its first real dataServerkind
dashboard_createdThe user makes the thing your product is forServertype
dashboard_sharedThey show it to someone elseBrowserchannel
invite_sentA teammate is invitedServerrole
checkout_startedThe upgrade dialog opensBrowserplan, interval
plan_startedThe billing provider confirms the subscriptionServerplan, seats, interval
plan_cancelledThe subscription endsServerplan, reason

Page views are not in the table because a browser SDK records them for you. Do not add events for every button. A click that matters shows up as the event it causes: nobody needs upgrade_button_clicked when checkout_started exists.

The plan covers signup, activation and revenue. For retention, make sure the one or two actions a healthy account repeats every week are events too. In this plan that is dashboard_created. The later parts of the series also use a few events added after this first plan, such as onboarding_viewed, docs_opened and query_run.

Naming rules

The event name is the key every funnel step, chart and filter uses. Three rules keep names usable:

  • One form. Lowercase snake_case, an object then a past-tense verb: invite_sent, plan_started. Mixed forms (Signup Complete, signupDone, completed_signup) become three events that mean the same thing.
  • Name the fact, not the interface. plan_started survives a redesign. pricing_modal_green_button_clicked does not.
  • Never put a value in the name. plan_started_pro and plan_started_team should be one event with a plan property. Values in names multiply events and make "all plans" impossible to count.

Renaming is expensive

Stored events keep the name they were sent with. After a rename, charts show the old name ending and a new one starting, and every funnel that used the old name stops matching new data. Treat names like a public API: review them before they ship.

Properties

A property is a detail of one occurrence: the plan chosen, the signup method, the number of seats. Properties are what you filter and break down by later, so add the ones your questions name and stop there.

  • Use the same property name for the same thing on every event. plan everywhere, never plan on one event and tier on another.
  • Keep values to a small fixed set where you can: google, github, email. Free text cannot be grouped.
  • Leave out personal data you do not need. An event rarely needs an email address when it already has a user id.

Properties of the person or the account are different from properties of the event. The plan chosen at one checkout belongs on the event. The plan an account is on today belongs on the account. The B2B guide covers when to use which.

Visitor, user, account

An event is only useful for funnels if the tool can tell that two events came from the same person. Three ids do that work:

IdWhat it isSet by
Visitor idAn anonymous id for a browser or a mobile installThe browser SDK, or your app for an install id
User idYour own id for a signed-in userYour code, at sign-in
Group idThe account, workspace or organizationYour code, with the user

The signup funnel crosses the sign-in boundary: signup_started comes from an anonymous visitor and plan_started from a known user. Call identify() as soon as the user is known, and send the same user id from your backend. Maple links a visitor to the user it becomes, so the anonymous visit and the signed-in activity count as one person.

Use the id from your database, not an email address. Emails change, and two people can share one.

Client or server

Send an event from the place where the thing happens. A page view or the opening of a dialog happens in the browser. An account being created or a payment succeeding happens on the server, and only the server knows it succeeded.

Browser events are lost to ad blockers, closed tabs and failed requests. That is acceptable for checkout_started and not for plan_started. If a number will be compared with revenue, send it from the backend.

Send the events

Maple accepts product events from three places. All three carry the same user, group and visitor ids, so one funnel can mix them.

From the browser

The browser SDK records page views on its own. Custom events are one call:

app.ts

import { MapleBrowser } from "@maple-dev/browser"

MapleBrowser.init({ ingestKey: "maple_pk_...", serviceName: "acme-web" })

// Once the user is known. Before this, events carry the anonymous visitor id.
MapleBrowser.identify({ id: user.id, groupId: org.id, groupName: org.name })

MapleBrowser.track("checkout_started", { plan: "pro", interval: "year" })

From a span you already emit

If the backend is traced with OpenTelemetry, the handler that starts a plan already produces a span. One attribute turns that span into a product event, linked to the trace that did the work:

billing.ts

// Inside the handler that creates the subscription.
span.setAttributes({
  "maple.product_event.name": "plan_started",
  "maple.product_event.user_id": user.id,
  "maple.product_event.group_id": org.id,
  "maple.product_event.include": "plan,seats,interval",
  plan: "pro",
  seats: 12,
  interval: "year",
})

Without maple.product_event.include, every attribute on the span becomes an event property. See product events from traces.

Over HTTP

Anything that can make an HTTP request can post events: a webhook handler, a batch job, a mobile app. The body is one JSON object per line.

curl -X POST https://ingest.maple.dev/v1/events \
  -H "Authorization: Bearer YOUR_INGEST_KEY" \
  -H "Content-Type: application/x-ndjson" \
  --data-binary $'{"name":"plan_started","user_id":"user_123","group_id":"org_456","attributes":{"plan":"pro","seats":12}}\n'

The events API reference lists every field and limit.

Check what arrives

Trigger each event once in a test account, then read the list. In Maple, Product analytics opens on the Events tab: every event name in the time range, its kind, and how many events, sessions and people it has.

The Events tab of Product analytics in Maple over the last week: 49.9K events under 9 names, and a table listing $pageview, signup_started, signup_completed, query_run and others with their kind, event count, sessions and people, each with Funnel and Paths links.
The Events tab, on example data. Each row starts a funnel or a path from that event.

Three things to look for:

  • Names you did not plan. A typo or a second naming form shows up as its own row.
  • People lower than expected. If plan_started has events and no people, the server is not sending a user id.
  • Events far above people. An event that fires in a render loop or on every keystroke has thousands of events per person.

Common mistakes

  • Tracking the click instead of the outcome. A click on "Create account" is an attempt. Send signup_completed when the account exists.
  • Different ids in the browser and the backend. If the browser identifies by email and the server sends a database id, every person is counted twice and no funnel crosses the two.
  • Events before identify. Call identify() when the session is restored on page load, not only at sign-in.
  • Changing what an event means. If dashboard_created starts firing for drafts too, the chart jumps and nobody remembers why. Add a new event instead.
  • Test traffic in the numbers. Keep development and staging out of production data, and decide how to exclude your own team before reading a conversion rate.
  • No owner. Keep the plan in the repository next to the code that sends the events, and change it in the same pull request.

Coming from PostHog

The model is the same: named events, properties, an anonymous id that merges into a user at identify. The calls map like this:

PostHogMaple
posthog.capture(name, props)MapleBrowser.track(name, props)
posthog.identify(id, props)MapleBrowser.identify() with id and traits
posthog.group(type, key)groupId in identify(), group_id on server events
$set and $set_onceset and set_once on the events API
$pageviewRecorded by the browser SDK
AutocaptureNo equivalent. Clicks appear in session replay, and events are explicit calls.

A few differences to plan for. Maple has one group id per event where PostHog allows several group types. And Maple does not turn clicks into events on its own, so an event plan like the one above is required from day one. PostHog also bundles feature flags, experiments and surveys, which Maple does not have. Mobile apps send events to Maple through the HTTP API.

Maple

Product events next to your traces

Maple stores product events for 365 days beside the traces, logs and session replays of the same users. A funnel step that comes from a traced request links back to the request behind it.

FAQ

よくある質問

What is an event tracking plan?
A tracking plan is the list of events a product sends, with the name of each one, when it fires, where it is sent from and which properties it carries. It is written before the code, so that every event answers a question someone will ask.
How many events should a product track?
Start with about ten: the steps of signup, the first action that delivers value, the actions that predict retention, and the billing changes. Add an event when a question cannot be answered without it. Hundreds of events nobody reads make the useful ones harder to find.
What is a good event naming convention?
Lowercase snake_case, an object followed by a past-tense verb: signup_completed, invite_sent, plan_started. Pick one form and keep it. The name is the key every funnel and chart uses, so renaming an event later splits its history in two.
Should events be tracked on the client or the server?
Track an event where the thing actually happens. A click or a page view happens in the browser. An account being created or a subscription starting happens on the server, and the server is the only place that knows it succeeded. Server events also survive ad blockers and closed tabs.
What is the difference between an event property and a user property?
An event property describes one occurrence: the plan chosen at this checkout. A user property describes the person: the plan they are on today. Use event properties for facts that were true at that moment, and user properties for the current state you want to filter everyone by.

今日、最初のトレースを。

SDKを追加し、OTLPエクスポーターをMapleに向ければトレースが届きます。

maple.dev:OpenTelemetryの上のオブザーバビリティ