Track events
Custom events
A custom event records something a visitor did — a signup, a button click, a video play. Page views are automatic; everything else is one track() call.
The basics
Once the script is on the page, call window.servoki.track() with an event name:
window.servoki.track('signup');The name is any short string you choose. Use a consistent, lowercase, verb-like convention (signup, play_video, add_to_cart) so events group cleanly in your dashboard.
Adding properties
Pass an object as the second argument to attach context. Properties let you break a single event down by any dimension later — plan, category, variant:
window.servoki.track('signup', {
plan: 'pro',
referrer_campaign: 'spring-launch'
});Keep properties to a handful of low-cardinality values (a plan name, a category) rather than unique ids — they're for grouping, not storage. Never put personal data (emails, names) in properties; Servoki masks obvious PII, but the cleanest path is to not send it.
Common examples
A button or CTA click
document.querySelector('#upgrade-btn')?.addEventListener('click', function () {
window.servoki.track('upgrade_click', { location: 'navbar' });
});A video play
videoEl.addEventListener('play', function () {
window.servoki.track('play_video', { title: 'product-tour' });
}, { once: true });Wait for the tracker to be ready
The script loads with defer, so window.servoki exists by the time your DOM handlers run. If you fire an event extremely early (inline in <head>), guard it:
window.servoki && window.servoki.track('early_event');Make it a conversion. Any event can become a measured goal with revenue and funnels — see Goals.
Verify it works
- Open your site and trigger the action.
- Open Realtime in your dashboard — the event appears in the live stream within a few seconds.
- In DevTools → Network, a
200POST toservoki.com/api/eventconfirms it left the browser.