Event tracking and product analytics
You cannot improve what you cannot see. Write a short tracking plan before you build, name events as an object and a past action, send important events from the server after the action really happened, link anonymous and logged in users, and never send personal data you do not need. Then read adoption, repeat use and retention of the feature, not only clicks.
Author: bezzad
Contents
The problem: three dashboards, three answers
Our shop launched “Notify me when cheaper”. A month later, the team asked a simple question: how many customers use it?
- The marketing dashboard said 9,000. It counted the event “Notify Click” sent from the browser.
- The product dashboard said 5,200. It counted “notify_subscribe”, sent by a newer app version.
- The database said 6,100 active alerts.
Nobody could answer. The events had different names in the web and the app. Some were sent when the user clicked, even if the request failed. Ad blockers removed others. And one event put the customer’s email address in a property, which the privacy team was not happy about.
Tracking is part of building a feature. If it is wrong, every decision after it is wrong too.
Start with questions, not events
Before you add any event, write the questions you want to answer. Then add only the events you need for them.
For “Notify me when cheaper”:
- Do people find it? How many see the button?
- Do they use it? How many turn on an alert?
- Does it bring value? How many alerts lead to a purchase?
- Do they keep using it? Do people set a second alert within 30 days?
This short list is your tracking plan. Put it next to the code, and review it like code.
| Event | When it is sent | Properties | Sent from |
|---|---|---|---|
| price_alert_button_viewed | The button appears on screen | product_id, platform | Client |
| price_alert_created | Alert saved in the database | product_id, price, platform | Server |
| price_alert_email_sent | The email was sent | alert_id | Server |
| order_placed | Payment done, order saved | order_id, total, from_alert | Server |
Naming events
Good names make every chart easy. Bad names make every chart a puzzle.
- One style everywhere. For example, lowercase words with underscores.
- Object, then a past action. “price_alert_created”, “order_placed”, “cart_viewed”. The action already happened.
- The same name on every platform. Web and app send the same event. The platform goes in a property.
- No values in the name. Not “button_red_clicked”. Use one event with a “color” property.
- Properties for details. Product id, price, source page, flag version.
// Bad: different style, a value inside the name, no details.
track("Notify Click Red Button");
// Good: one style, object + past action, details as properties.
track("price_alert_created", {
productId: product.id,
price: product.price,
platform: "web",
});
Send important events from the server
An event sent from the browser has problems:
- It can be lost. Ad blockers, closed tabs and bad networks stop many browser events.
- It can be sent too early. “Clicked pay” is sent even when the payment fails.
- It can be faked. Anyone can send any event from the browser.
A simple rule:
- Results (order placed, alert created, payment failed) are sent from the server, after the action really succeeded.
- Things only the browser knows (a button came into view, a page was scrolled) are sent from the browser.
- Never use analytics events as the truth for money. Revenue comes from the database. Events are for understanding behavior.
Who is the user?
The same person often starts logged out on the phone and finishes logged in on a laptop.
- Anonymous id. Before login, the tool gives the visitor a random id, usually stored in a cookie.
- Identify on login. When the user logs in, tell the tool that this anonymous id is this user id. Then the steps before login are linked to the user.
- Use your own stable id. Use the database user id, not the email. Emails change.
- Reset on logout. On a shared computer, the next person must not be linked to the last one.
Privacy: send only what you need
Analytics data is copied to other tools and kept for a long time. Treat it carefully.
- No personal data in events unless there is a clear need: no emails, phone numbers, addresses or names in properties.
- Hide inputs in session recordings. Most tools can mask text fields. Check that they really do.
- Respect consent. Follow the laws where your users live, for example the GDPR in the European Union, and your own privacy policy.
- Keep data only as long as you need it.
Reading usage: is the feature really used?
Clicks are not success. For a new feature, look at these steps:
- Reach. How many people saw the feature? If few see it, the problem may be where it is placed, not the feature.
- Adoption. How many used it at least once?
- Repeat use. How many used it again? A feature people use once and forget is not solving a real problem.
- Retention. Are people still using it after 30 or 60 days?
- Value. Does it lead to the result you care about, for example a purchase?
Then look for the why: session recordings, support tickets and short talks with users. Numbers show where people stop. People tell you why.
Keep the data healthy
- Test events like code. In a test, check that the right event with the right properties is sent.
- Check new events after release. On day one, look at the raw events. Are the counts close to the database?
- Version the tracking plan. When an event changes meaning, give it a new name, or the old charts lie.
- Remove events nobody uses. They cost money and attention.
Common mistakes
| Mistake | Result | Right way |
|---|---|---|
| Adding events without questions | Many events, no answers. | Write the questions first, then a tracking plan. |
| Different names on web and app | Numbers do not add up. | One name, platform as a property. |
| Sending “clicked” instead of “succeeded” | Failed actions are counted. | Send results from the server after success. |
| Using email as the user id | Broken history when it changes, privacy risk. | Stable database id, identify on login. |
| Personal data in properties | Privacy and legal risk. | Send only what you need. |
| Counting clicks as success | One-time curiosity looks like adoption. | Look at repeat use, retention and value. |
| Never checking event data | Charts lie for months. | Compare with the database after release. |
Summary in six lines
- Start from questions, then write a short tracking plan.
- Name events as an object and a past action, the same on every platform.
- Send results from the server after they really happen.
- Link anonymous and logged in users with a stable id, and reset on logout.
- Never send personal data you do not need.
- Judge a feature by repeat use, retention and value, not by clicks.