---
title: "Product analytics · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/product-analytics
updated: 2026-10-20
licence: "All rights reserved"
---

# Product analytics

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

> Plan every event in code and validate it. Keep people out of it, record business facts on the server, and fix experiment rules before the start.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/product-analytics`.

## Required

- [Keep a tracking plan in the code](https://agentwranglers.se/playbook/data/product-analytics/tracking-plan): List every analytics event in one file in the repository, with its name, purpose, owner and properties. Name events as an object and a past-tense action.
- [Validate every event before you store it](https://agentwranglers.se/playbook/data/product-analytics/event-validation): Check each incoming event against its schema at the collector. Store valid events, and set invalid ones aside with the reason.
- [Track only after consent](https://agentwranglers.se/playbook/data/product-analytics/analytics-consent): Send no analytics event that uses device storage or identifies a person until that person has agreed. Read the stored choice in the tracking module itself.
- [Keep personal data out of events](https://agentwranglers.se/playbook/data/product-analytics/events-without-personal-data): Never put names, email addresses, phone numbers, free text or full URLs with query strings in event properties. Use an internal ID that analytics cannot turn back into a person.
- [Record business facts on the server](https://agentwranglers.se/playbook/data/product-analytics/server-side-business-events): Record events that count money, sign-ups or other business facts on the server, at the moment the fact is committed. Use browser events only for behaviour in the page.
- [Write the experiment plan before it starts](https://agentwranglers.se/playbook/data/product-analytics/experiment-plan): Before an A/B test starts, write down its one primary metric, guardrail metrics, minimum effect, sample size and stop date. Decide only at that sample size.
- [Assign each user to one variant for good](https://agentwranglers.se/playbook/data/product-analytics/experiment-assignment): Assign variants by hashing a stable user ID with the experiment name, so a person sees the same variant on every visit and device. Log an exposure when the variant is shown.
- [Delete raw events on a schedule](https://agentwranglers.se/playbook/data/product-analytics/analytics-retention): Keep raw events with an analytics ID for a fixed time only, such as 14 months. Then delete them or roll them up into counts without IDs.

## Recommended

- [Define each metric once](https://agentwranglers.se/playbook/data/product-analytics/metric-definitions): Define every business metric once, in version control, and build every dashboard and report from that definition.
- [Keep test and bot traffic out of the numbers](https://agentwranglers.se/playbook/data/product-analytics/exclude-test-traffic): Mark every event from staff, test accounts, automated tests and known bots at the collector, and leave marked events out of every metric.

- Previous: [Caches and copies](https://agentwranglers.se/playbook/data/caches-and-copies)
- [All chapters](https://agentwranglers.se/playbook/data)
