Guides

How to track events in analytics — and why a parameter won't show up on its own

Illustration: separate markers along a path instead of one turnstile at the door

You installed a counter on your site and you can see it: 400 visits. Great. And then it's a dead end — that number can't tell you whether anyone reached the button the whole thing was built for.

By default a counter counts pages. You need actions. That's a separate job, and it takes an evening.

A warning up front about the rake everybody steps on: sending an event with a parameter isn't enough. The parameter can fly out honestly for a week and appear in exactly zero reports until you manually tell analytics you want to see it. That's step 5, and it's better read before you start.

Step 1. Pick 3–5 events, not fifty

The temptation is to tag everything. Don't: in a month you'll have two hundred names and remember none of them.

Take the user's path to value and put a marker at every turn:

  • started signup
  • signed up
  • created a first project
  • came back and created a second

Four events are already enough for an honest funnel. You don't need clicks on the logo — you'll never make a decision from them.

Step 2. Choose names you won't have to change

An event name is the key that stitches the whole history together. Rename it in a month and the old data stays under the old name, splitting your chart in half. So the rules are simple:

  • lowercase and underscores: project_created, not Project Created;
  • object first, then the action in past tense: signup_started, project_created, file_uploaded;
  • no spaces, no hyphens, no non-Latin characters;
  • anything variable goes in a parameter, not in the name. project_created with template: "blank" is right. Separate project_created_blank and project_created_ai events are a dead end — you can't add them up.

Step 3. Send the event from your code

At its simplest, it's one line where the action happened. For web analytics on gtag.js:

gtag('event', 'project_created', {
  template: 'blank',
});

The first argument is always 'event', the second is your name from step 2, the third is an object of parameters.

Put the call after success, not on the button click. The difference matters: a click is intent, and you need the fact. Otherwise failed attempts land in your stats as successes, and the funnel paints a prettier picture than reality.

const res = await fetch('/api/projects', { method: 'POST' });
if (res.ok) {
  gtag('event', 'project_created', { template: 'blank' });
}

You can send up to 25 parameters on one event — plenty of headroom. There's no limit on distinct event names for a web stream, but see step 1: the real constraint isn't technical, it's your memory.

Step 4. Verify in a minute, not in a day

The most common way to lose time: tag everything, walk away, discover two days later that nothing arrived. Check immediately — realtime and debug reports exist for this and show events the moment they fire.

  1. Open your site in one tab and the realtime report in another.
  2. Do the action yourself.
  3. The event should appear in the list within seconds.

If it doesn't, it's almost always one of three things: an ad blocker in your browser is killing the request (check in a private window with no extensions), the analytics snippet didn't load on that page, or execution simply never reached your call — drop a console.log next to it and confirm.

Step 5. Register your parameters, or they won't be in reports

Here's the rake. The project_created event will show up in reports by itself. The template parameter inside it will not. It's sent, it's stored, but to slice a report by it you have to declare it separately as a custom dimension in settings.

Two consequences worth a lost week:

  • values appear in reports 24–48 hours after the data starts flowing and the parameter is registered. Not in a minute;
  • register a parameter as soon as you start sending it. Reports begin collecting that breakdown from that moment — you can't get it retroactively.

So the order is: add the parameter to the code → go declare it in settings right away → look a day later.

Step 6. Turn the events into a funnel

You now have four names. Count not "how many times each fired" but how many unique users reached each step, then divide neighbouring numbers by each other. The percentages between adjacent steps are your answer to "where is it narrow".

What you get

Instead of one number — "400 visits" — a chain like 400 → 120 → 48 → 11. From that it's immediately clear that 70% drop off without starting, and that's a concrete task for tomorrow. And once you have a couple of weeks of events, the same data can be sliced into cohorts to see whether your fix actually helped.

How long before I can draw conclusions?

A week, and at least a couple of hundred people at the first step. On twenty visitors, one random drop moves a percentage by five points — that's noise. While numbers are small, watching individual sessions beats watching percentages.

Do I need consent for this kind of tracking?

If events are tied to a person through cookies or an identifier — yes, most jurisdictions want a consent banner, same as for a plain counter. Fully anonymous "how many times was this pressed" counting is usually simpler, but it depends on your country and on what you put in the parameters. Never put personal data in parameters.

Can I track events without an external service?

Yes, and early on it's often more honest: store a (user_id, event_name, created_at) row in your own database. One query and you have a funnel. An external service earns its place when you want to slice data with a mouse instead of writing a query per question.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →