Skip to content

Custom events

Custom events measure the actions that matter — sign-ups, purchases, downloads — beyond page views.

mad.track('purchase', {
plan: 'pro',
amount: 49,
currency: 'EUR',
});
Argument Type Description
name string The event name. Free-form, but keep it stable and lowercase.
properties object Optional. Key–value pairs you can filter and break down by.

The event is attached to the visitor’s current visit, so you can see the pages that led up to it.

Properties accept strings, numbers, and booleans:

mad.track('video_play', {
title: 'Morning show',
duration: 1830,
live: true,
});

Numbers can be aggregated (sum, average) in the dashboard; strings and booleans are grouped.

For simple clicks, add data attributes and the tracker handles the event — no JavaScript required:

<button
data-mada-event="download"
data-mada-event-file="report.pdf"
>
Download report
</button>

The data-mada-event value becomes the event name; every data-mada-event-* attribute becomes a property. mada is the canonical attribute prefix — mad and umami are also recognized, in that priority order, so existing Umami click-tracking markup keeps working unchanged.

To attach an identifier to a visit — without using cookies or personal data — call identify once you know it:

mad.identify('user_182', { plan: 'pro' });

Pass a role, plan, or hashed ID here, never an email address or name. See Privacy.

  • Name in snake_case, lowercase — checkout_started, not Checkout Started.
  • Vary with properties, not names — one purchase event with a plan property beats purchase_pro and purchase_hobby.
  • Never send personal data — no emails, names, or user IDs. See Privacy.