BlogHow-to

How to track custom events in web analytics

Abbas Aga
Abbas Aga · 1 min read

TL;DR:
To track a custom event, mark the action three possible ways: add a data attribute to the element (no code), define a no-code rule in your dashboard, or call the tracker's JavaScript API. Each records a named event you can then report on, count toward conversions, and attach a value to. Cookieless tools do all of this without a consent banner.

A pageview tells you someone arrived; a custom event tells you they did something, signed up, bought, clicked the thing that matters. Tracking events is how analytics goes from traffic to outcomes. There are three ways to do it, from no code at all to a one-line call, and you can mix them.

  1. 1

    The no-code way: a data attribute

    Add a data attribute to the element you want to track, and the tracker records a named event when it is clicked, no JavaScript, no deploy of app logic. This is the fastest way to tag a button or link.

    <button data-oa-event="signup">Sign up</button>
  2. 2

    The no-code way: a dashboard rule

    Define a rule in your analytics dashboard that turns a matching click or pageview into a named event. Useful when you cannot edit the markup, or want to manage events without touching code.

  3. 3

    The code way: the JavaScript API

    For events that fire from your own logic (a successful payment, a form validated) call the tracker's function with an event name and optional properties. This is the most precise, and the right choice for anything that is not a simple click.

    oa.track("purchase", { plan: "growth", value: 19 })
  4. 4

    Attach a value, then report

    Give conversion events a value (a purchase amount, a plan price) so your reports can total revenue by event, not just count occurrences. Then read the event in your dashboard: how often it fires, from which pages, and (if the tool attributes revenue) which source produced it.

Name events consistently and keep the list short. A dozen well-named events you actually read beats a hundred you tagged and forgot.

Open Analytics tracks events three ways (data attributes, no-code rules, or the JS API) cookielessly, and ties valued events back to their source.

See custom events

Frequently asked questions

What is a custom event in analytics?
A custom event is any action you choose to track beyond a pageview, a signup, a purchase, a click, a form submit. You give it a name (and optionally a value), and analytics counts it, reports on it, and can treat it as a conversion. It is how you measure outcomes, not just traffic.
Can I track events without writing code?
Yes. Add a data attribute to the element, or define a no-code rule in your dashboard, and the event is tracked with no JavaScript. Code is only needed for events that fire from your own logic, like a confirmed payment, where the JavaScript API is the precise option.
Does event tracking need cookies?
No. Custom events are tied to the current anonymous visit, which cookieless tools handle with a daily-rotating signal rather than a persistent cookie. Open Analytics tracks events with no cookie set and no consent banner required.