Skip to content
all posts
Guide 2 min read updated July 20, 2026

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.

By Sourav · Building sonex
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.

Name events for the action, not the element: signup, not header-button-2. Consistent, human names are what make funnels and goals readable weeks later.

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:

  • signup to know if people join
  • checkout to know if they pay
  • cta-click to 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.

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
Questions

Frequently asked.

Cookies, install and pricing, answered. Still stuck? Ask us anything .

01 Can sonex show revenue next to my traffic?

Yes. Connect Stripe or Polar with a read-only key and sonex reads revenue straight from your payment provider, per website. Revenue then appears as a focusable series on the Overview chart and as its own report, beside the traffic that earned it. No tracked event is needed for it to work.

02 Does sonex use cookies?

No. sonex sets no cookies and needs no consent banner. It counts visits without cookies, fingerprinting, or any personal data, so it is GDPR, PECR and CCPA-ready by default.

03 How do I install sonex?

Add one script tag to your site's <head> with your website id. It is a single lightweight tracker — no build step and no SDK required.

04 Is sonex a Google Analytics alternative?

Yes. sonex gives you the reports that matter — visitors, pages, referrers, funnels, revenue and a world map — without surveilling your audience or drowning you in configuration.

05 How is sonex priced?

By monthly tracked events. Free covers 2k events, Pro is $20/mo for 200k events, and Business is $200/mo for 2M events with team seats.

See what your traffic actually earns.

Revenue beside the visitors that produced it. No cookies, no credit card, no consent banner.

Get started