Loading…

Integration

Browser API reference

track, conversion, page, identify, experiments, and flush.

window.Tracuto is the hosted-loader API. Always check isReady() before other methods.

Method reference

MethodSignatureWhenNotes
tracktrack(name, { category?, label?, value?, blockId?, elementId?, metadata? })Explicit business or product eventsUse after isReady(); not required for automatic contextual clicks
conversionconversion(name, value?, metadata?)Funnel outcomes with optional revenue in valuePut currency, order id, and line items in metadata
pagepage(metadata?)SPA or soft navigations without full reloadFires a page view with optional route metadata
identifyidentify(attributes)After login or when session fields changeString, number, or boolean keys; user_name sets display label
setUserIdsetUserId(userId)Stable account id from your auth systemStitches sessions; call before or with identify
clearUserIdclearUserId()LogoutPair with flush() so pending events send before navigation
errorerror(error, metadata?)Uncaught or handled client errors you want in analyticsPass Error object; add context in metadata
flushflush()Before redirect or after identify/logoutSends queued analytics promptly
isReadyisReady()Before any other call on hosted loaderFalse until bundle loaded and tracker started
getExperimentVariantgetExperimentVariant(experimentKey)Branch UI by variant id or nameReturns assignment or null; matches dashboard experiment key
isExperimentEnabledisExperimentEnabled(experimentKey, mode?)Gate treatment vs control UImode: 'any-assignment' | 'non-control' | 'control' (default any-assignment)
getInstancegetInstance()Advanced debugging onlyReturns underlying PearTracking; prefer window.Tracuto methods

Guard pattern

javascript
if (window.Tracuto?.isReady?.()) { window.Tracuto.track('cta_signup_click', { category: 'hero', label: 'Get started' }); window.Tracuto.conversion('signup_completed', undefined, { source: 'integration_guide' }); }

SPA page views

Full page loads are automatic. After client-side route changes, call:

javascript
// SPA page views are tracked automatically when using the Tracuto loader // or AnalyticsPlugin with autoTrackPageViews (default). History API navigations // (pushState, replaceState, popstate) emit page_view events for funnel analytics. // Manual call only needed for custom routers without History API, or when // autoTrackPageViews / trackSpaNavigations is disabled: if (window.Tracuto?.isReady?.()) { window.Tracuto.page({ route: '/settings/billing', source: 'spa' }); }

We ask before enabling optional analytics (including our own Tracuto script) or marketing cookies. Essential cookies are always used to run the service securely. See our Privacy Policy.