Docs

Servoki developer docs

Everything beyond the basic page view. Pick a trigger and copy the code — every snippet is real, runnable, and uses the same lightweight tracker you already installed.

Not installed yet? Start with the install guide — one script tag and page views start flowing. Then come back here to track the things that matter.

Start here

Track events in the browser

Conversions & revenue

Sharing

Server-side

The tracker API, in one place

After the script loads, it exposes a tiny global. Two methods, that's the whole surface:

// record an event (with optional properties)
window.servoki.track('signup');
window.servoki.track('purchase', { plan: 'pro', value: 49 });

// tie this browser to an id you control (for server-side stitching)
window.servoki.setVisitor('anon-abc123');

Setting the visitor id or consent before the first page view

The page view is sent the moment the script runs, so a setVisitor() made afterwards only reaches later events — and the page view lands on a different visitor than your own events. If you use setVisitor() or a consent banner, add this one-line stub before the Servoki script tag and make your calls through it. They are queued and applied before the first page view; queued track calls are sent right after it.

<script>window.servoki=window.servoki||function(){(servoki.q=servoki.q||[]).push(arguments)};</script>
<script defer data-site="example.com" src="https://servoki.com/tracker.js"></script>
<script>
  servoki('setVisitor', 'anon-abc123');   // same id you send with server events
  servoki('consent', true);                // if your banner already has consent
  servoki('track', 'view_item', { sku: 'A1' });
</script>

The command form keeps working after the script has loaded, so the same calls are safe at any point in the page’s life.

Page views fire automatically on load. Everything else is a track() call you place where the action happens. The tracker sets no cookies and respects Do Not Track.