Skip to Content
ReferenceAnalytics and consentBrowser integration API

Browser integration API

Audience: Developer and Integrator.

This reference defines the JavaScript API available to trusted browser integration scripts.

Integration API

analytics.subscribe(name, callback)

Subscribe to a standard event or all_events. The method returns an unsubscribe function. A callback can return a promise. The runtime records a failed callback. It does not stop other subscribers or the application action. Before delivery, the runtime validates current consent and the active selection, including for queued callbacks. Consent withdrawal invalidates queued delivery.

customerPrivacy.getState()

Read { resolved, allowed, consent }. allowed describes the integration’s current permission. Consent keys come from the configured CMS consent records.

customerPrivacy.subscribe(callback)

Listen for consent changes. The method returns an unsubscribe function. Forward changes to a vendor’s consent API when its SDK needs them. Analytics and functional consent remain separate permissions. The integration script must forward changes to any vendor SDK that it loads.

runtime.onDispose(callback)

Register cleanup for timers, listeners, and requests that the integration owns. The method returns a function that removes the cleanup callback. Cleanup runs on consent withdrawal, configuration change, unmount, and scope exit. It also runs when configuration reload disables the integration.

const timer = setInterval(() => { // Run permitted local work. }, 1000); runtime.onDispose(() => clearInterval(timer));

Diagnostics and validation

Read the latest 100 metadata-only diagnostics in the browser console:

window.hitoApp.integrations.inspect();

Diagnostics include integration IDs, event IDs and names, status, and a reason. They exclude payloads. Delivered means that the runtime forwarded the event to a subscriber.

Script delivery and security

The CMS resolves script URLs from APP_API_BASE_URL. This URL must be accessible from the visitor’s browser. Scripts load from /v1/browser-integrations/:id.js below that API base path. Disabled and deleted integrations return 404 after the CMS save notification clears the backend query cache.

The backend sends JavaScript with nosniff, a restrictive CSP, and no-referrer headers. Browsers can store the response, but must revalidate it before reuse. Unchanged responses use ETags and return 304. If a CMS save reports an update warning, use its retry action before you test the changed script.

The loader omits cross-origin credentials and referrer information. The API’s configured CORS origins control cross-origin loads. Integration URLs are public. The storefront CSP must permit the API and vendor resources. The loader does not require unsafe-eval. See the runtime and consent explanation for trust boundaries and vendor cleanup.

Implementation and validation

The shared event service uses the browser’s EventTarget. Storefront setup uses this implementation. Tests cover enabled configuration, consent, scope, cleanup, failure isolation, cart ordering, and configuration loading. Source changes require affected package tests and repository checks.

Use the event reference for payloads, triggers, replay, and exclusions.

Last updated on