I've lost count of how many Google Analytics accounts I've seen like this: hundreds of events with similar names (click_button, button_click, cta-click), half of them without parameters, nobody knows who created them and nobody trusts the numbers. The tool isn't to blame. There was no plan before the first event.
Start with the questions, not the events
The most common mistake is to track everything "just in case". That creates noise, cost and, under privacy laws like Brazil's LGPD and Europe's GDPR, risk. The opposite path works better:
- Which decisions will we make with this data? "Is campaign X worth keeping?", "Did the new onboarding activate more people?"
- Which questions answer those decisions? "What's the cost per activated account, per channel?"
- Which events and parameters answer those questions? Only now do you write the event.
If an event doesn't answer any question, it doesn't go in.
A taxonomy that scales
Event names are an API: once published, changing them is expensive. A few rules I use:
object_actionin the past tense, in snake_case:signup_completed,report_generated,plan_selected. Putting the object first groups the events about the same subject together in the list.- Parameters carry the context, not the name. Instead of
signup_googleandsignup_email, onesignup_completedwithmethod: 'google' | 'email'. - Names and values in English, with no accents or spaces. It avoids surprises in reports and exports.
- A versioned dictionary. A table in the repository with the event, when it fires, its parameters and who asked for it.
| Event | When it fires | Parameters |
|---|---|---|
signup_click | Click on any sign-up CTA | location (hero, pricing, header) |
price_interest | Pricing section visible for 2s | currency |
signup_completed | Account created successfully | method |
first_value | First action that delivers value | days_since_signup |
signup_click happens on the site and signup_completed in the app. The measurement plan crosses repositories, so it needs to be written somewhere both teams read.The event ships in the same PR as the feature
Measurement patched in later is always incomplete. The rule that works: a feature without its event isn't done. The acceptance criteria include "event X fires with parameters Y", and the review checks it.
In practice, I centralize tracking in a single composable or service, so no component talks directly to gtag:
export function useTracking() {
const consent = useConsent()
function track(event: TrackingEvent, params: Record<string, string | number> = {}) {
// Without consent for measurement, nothing leaves the browser
if (!consent.value.analytics) return
window.gtag?.('event', event, params)
}
return { track }
}
That gives you three things: a single place to respect consent, a type (TrackingEvent) that prevents made-up names and one point to switch tools in the future without hunting calls across the code.
Consent isn't a detail
Under the LGPD (and the GDPR, if you serve Europe), measurement and consent go together. The design I usually propose:
- Necessary cookies always on (session, preferences);
- Measurement (GA4) and marketing (ad pixels) as separate categories, each with a defined legal basis and a recorded choice;
- A clear banner, with accept, decline and customize at the same level, no hidden button;
- The choice stored in its own cookie and a permanent link in the footer to review preferences;
- A cookie policy that says in plain language what is collected and why.
Validate before you trust
Before using a number to make a decision, check:
- Does the event show up in GA4's DebugView with the right parameters?
- Are the important parameters registered as custom dimensions?
- Does the volume match another source (database, Stripe, CRM) within a reasonable order of magnitude?
- Do people who declined consent really send nothing?
Summary
A good measurement plan fits on one page: the decisions, the questions, the event dictionary and the consent rules. It costs an afternoon at the start and saves months of data nobody trusts. And it has a nice side effect: it forces product, engineering and marketing to agree, before building, on what "working" means.
Murilo Anzini
Hands-on writing on engineering, product, data and marketing for people who want to understand, and build, the whole journey of a product.
A North Star without vanity: how to choose the metric that really guides the product
Registered users, pageviews and downloads make pretty charts and bad decisions. A guide to choosing the metric that matters and building the tree that connects the team's work to it.
Meta Ads or Google Ads? The right question is: does the demand already exist?
Comparing ad platforms by cost per click is comparing tools built for different jobs. A more useful way to decide: capturing demand or creating demand.