Custom events
Measure the things that matter to you: signups, clicks, plays, purchases.
All pages
The tracker records pageviews on its own. Everything else, you send.
There are two ways, and they do the same thing. Use markup when the event is “someone clicked this element”. Use JavaScript when the event happens in your code.
In your markup
Add data-sonex-event to any element. Clicking it sends that event:
<button data-sonex-event="cta-click">Start free</button>
Extra data-sonex-event-* attributes become properties on the event:
<button
data-sonex-event="cta-click"
data-sonex-event-position="hero"
data-sonex-event-plan="pro">
Start free
</button>
That sends cta-click with position: "hero" and plan: "pro". Now you can tell your hero button from the same button in the footer, without inventing two event names.
In your JavaScript
window.sonex.track("signup");
window.sonex.track("signup", { plan: "pro", source: "pricing-page" });
Send it where the thing actually succeeded, not where it was attempted. A signup fired on button click counts people who tried; fired in your success handler, it counts people who made it. Those are different numbers, and only one of them is a signup.
Properties
Keep them low-cardinality: a plan name, a category, a variant. They are for slicing a count into groups you can compare.
Do not put unique values (emails, user ids, order numbers, full session ids) in properties. Every unique value is its own group, so the breakdown becomes a list with a count of 1 next to each row. That is not analysis, and it is personal data you did not need to send. Nothing in sonex asks you for it.
Tagging a whole site
data-tag on the script tag labels every event from that page, which is the clean way to separate environments or variants:
<script defer
src="https://api.trysonex.com/sonex.js"
data-website-id="YOUR_WEBSITE_ID"
data-tag="staging"></script>
Filter by tag later to include or exclude it.
Identify
window.sonex.identify("user_123", { plan: "pro" });
identify attaches your own stable id to the current session, so visits from a known account tie together across devices instead of counting as strangers. It is for products where people log in.
Do not use identify on a public marketing site. There is nothing to identify, and it weakens the property you are selling.
Turning events into answers
An event count is a starting point. Make it a rate with a Goal, a path with a Funnel, or a credit assignment with Attribution. See Reports.
Next: Links and pixels.