Data/Analytics

A measurement plan before the first event: clean GA4, with consent

Installing GA4 takes five minutes; trusting the data takes months if you start wrong. How I design the event taxonomy, consent and measurement flow together with the feature.

Murilo Anzini 3 min read

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:

  1. Which decisions will we make with this data? "Is campaign X worth keeping?", "Did the new onboarding activate more people?"
  2. Which questions answer those decisions? "What's the cost per activated account, per channel?"
  3. 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_action in 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_google and signup_email, one signup_completed with method: '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.
EventWhen it firesParameters
signup_clickClick on any sign-up CTAlocation (hero, pricing, header)
price_interestPricing section visible for 2scurrency
signup_completedAccount created successfullymethod
first_valueFirst action that delivers valuedays_since_signup
Notice that 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:

composables/useTracking.ts
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.

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.
The legal basis (consent or legitimate interest) and the default behavior vary by country and by case. It's a decision to make with whoever handles legal, not an implementation detail.

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.

#ga4#analytics#privacy#events#measurement

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.

About me

Free ebook

Criando infoprodutos de valor

The method I use to bring product, marketing and sales together when creating digital products: the way startups test hypotheses, understand needs and build what the market wants to buy.

  • Understand the customer and set the initial hypotheses
  • Build and test a lean MVP
  • Measure progress and validate with data
  • Know when and how to pivot
Download for freePDF · 23 pages · in Portuguese · no sign-up