Custom events
Custom events measure the actions that matter — sign-ups, purchases, downloads — beyond page views.
mad.track(name, properties?)
Section titled “mad.track(name, properties?)”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.
Property values
Section titled “Property values”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.
Track from HTML
Section titled “Track from HTML”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.
Identifying a visitor
Section titled “Identifying a visitor”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.
Conventions
Section titled “Conventions”- Name in
snake_case, lowercase —checkout_started, notCheckout Started. - Vary with properties, not names — one
purchaseevent with aplanproperty beatspurchase_proandpurchase_hobby. - Never send personal data — no emails, names, or user IDs. See Privacy.