Events & Goals

Tracking API

The client-side window.otus API for sending custom events and setting user properties.

Once the tracking script has loaded, it exposes a small global object — window.otus — for sending your own events and attaching context.

The tracker loads with 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?)
ArgumentTypeDescription
eventNamestringThe event name. Must match ^[a-z0-9_]{1,64}$ (lowercase, numbers, underscores). Invalid names are dropped.
paramsobject (optional)Key/value metadata for the event.
linkingIdstring (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'
});
Don't put personal data (names, emails, IDs that identify a person) in user properties or event parameters. Keep them to non-identifying attributes.

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 })
ArgumentTypeDescription
analyticsboolean (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.
marketingboolean (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 });
Both categories default to granted until 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.