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();
otus.setConsent()
Tells Otus which categories of processing a visitor has consented to. Intended to be called from your own cookie/consent-banner integration whenever the visitor grants or changes their choice — the same way you'd call Google Consent Mode's gtag('consent', 'update', …).
window.otus.setConsent({ analytics, marketing })
| Argument | Type | Description |
|---|---|---|
analytics | boolean (optional) | Whether the visitor consents to analytics. Recorded for every event, but doesn't currently change whether an event is stored — Otus's core analytics doesn't require consent by design. |
marketing | boolean (optional) | Whether the visitor consents to marketing. Controls whether events are forwarded to your connected ad platforms for server-side conversion tracking (CAPI). When false, matching events are never sent to any connection. |
// Visitor accepted analytics + marketing
window.otus.setConsent({ analytics: true, marketing: true });
// Visitor accepted analytics only — events are stored as usual, but never
// forwarded to Google/Meta/TikTok/OpenAI conversion APIs
window.otus.setConsent({ analytics: true, marketing: false });
// Only update one category — the other keeps its current value
window.otus.setConsent({ marketing: false });
setConsent() is called — matching Otus's cookieless-by-default, no-consent-banner-required positioning. Your choice is remembered in localStorage, so you only need to call setConsent() when the visitor makes or changes a choice, not on every page load.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.