Track custom events without a tag manager
A practical guide to tracking custom events with plain HTML attributes and a tiny JavaScript API, no tag manager, no consent layer, no bloat.
All posts
Custom events tell you whether people do the things that matter: sign up, add to cart, click the call to action. You do not need a tag manager to track them. With sonex there are two ways, and both take seconds.
The declarative way
For anything a visitor clicks, you can track it with attributes alone, no JavaScript:
<button data-sonex-event="signup" data-sonex-event-plan="pro">
Start free
</button>
The data-sonex-event value is the event name. Every data-sonex-event-* attribute rides along as a property, so this records a signup event with plan: "pro". This is the right tool for buttons, links and any static markup.
The programmatic way
When the event depends on something dynamic, a value, a result, a condition, call the tiny API:
window.sonex.track("checkout", { value: 49, currency: "USD" });
The first argument is the name, the second an optional object of properties. Use this inside a form handler, after a successful request, or anywhere a data attribute cannot reach.
Fewer, sharper events
Resist tracking everything. Three deliberate events beat three hundred automatic ones. Decide the question first, then track the two or three events that answer it:
signupto know if people joincheckoutto know if they paycta-clickto know if the button works
That is usually enough to build a funnel from visit to conversion that you can actually read.
Where the events show up
Tracked events appear in your dashboard as counts and inside reports. From there you can build a funnel to see where people drop between steps, or set a goal to watch a single action over time. Because the events carry your property names, the reports speak your language rather than a generic schema.
No consent layer to bolt on
A tag manager usually drags a consent layer along with it, because the tags it fires set cookies. sonex sets none, so there is nothing extra to configure and no banner to add. You annotate the markup or call one function, and the event is tracked, privately, from the first click.
Frequently asked questions
- Do I need a tag manager to track custom events?
- No. With sonex you track events either declaratively, by adding data-sonex-event attributes to an element, or programmatically with a one-line window.sonex.track call. There is no tag manager, no container, and no separate consent layer to configure.
- How do I track a button click?
- Add data-sonex-event="name" to the button, plus optional data-sonex-event-* attributes for properties. The click is recorded as a custom event automatically, with no JavaScript required.
- Can I attach properties to an event?
- Yes. Declaratively, every data-sonex-event-* attribute becomes a property. Programmatically, pass a plain object as the second argument to window.sonex.track. Keep properties few and meaningful for the clearest reports.
sonex is privacy-first web analytics. No cookies, no consent banner, no personal data. Drop one script and read realtime visitors, funnels and a world map in seconds.
Try sonex free