Tracking API
Once the tracking script has loaded, it exposes a small global object — window.otus — for sending your own events and attaching context.
defer, so guard calls that might run early with a check: if (window.otus) { … }. Events sent before load are simply not recorded.otus.track()
Send a custom or standard event.
window.otus.track(eventName, params?, linkingId?)
| Argument | Type | Description |
|---|---|---|
eventName | string | The event name. Must match ^[a-z0-9_]{1,64}$ (lowercase, numbers, underscores). Invalid names are dropped. |
params | object (optional) | Key/value metadata for the event. |
linkingId | string (optional) | An ID to correlate this event with a later one (e.g. linking a begin_checkout to its purchase). |
// Simple custom event
window.otus.track('newsletter_signup');
// With parameters
window.otus.track('signup_completed', { plan: 'growth', method: 'email' });
// A standard e-commerce event
window.otus.track('add_to_cart', { item_id: 'SKU-1', quantity: 1, value: 49.9, currency: 'EUR' });
otus.setUserProperties()
Attach persistent properties that are then sent with every subsequent event from that visitor — useful for plan tier, account type, or experiment group.
window.otus.setUserProperties({
plan: 'growth',
role: 'admin'
});
otus.clearVisitorId()
Clears the stored visitor identifier (relevant only in full tracking mode). Call this on logout if you want subsequent activity treated as a new visitor.
window.otus.clearVisitorId();
Opting a visitor out
To stop the tracker recording in a given browser, set a flag in localStorage:
localStorage.setItem('otus_ignore', 'true'); // stop tracking
localStorage.removeItem('otus_ignore'); // resume tracking
How events are sent
Events are delivered with navigator.sendBeacon (falling back to fetch with keepalive), so they survive page unloads and navigations. Delivery is fire-and-forget — failures never throw or interrupt your page.
Firing events from Google Tag Manager
You can call window.otus.track() from a GTM Custom HTML tag tied to a trigger. See the GTM guide.