Add a browser integration
Audience: Integrator.
Use this procedure to add a trusted CMS script to the storefront.
Prerequisites
- Use an account with at least the
MANAGERrole and bothCONTENT_ACCESSandADMIN_ANALYTICSpermissions. - Configure consent for the purposes that the integration requires.
- Use a published test storefront. Admin, development, unpublished, and draft-preview routes do not start the managed runtime.
- For the example below, provide a destination that accepts cross-origin JSON requests from the storefront.
- Select the required integration scope.
Setup
- Sign in to the CMS with at least the
MANAGERrole and bothCONTENT_ACCESSandADMIN_ANALYTICSpermissions. Create a Browser integration. - Enter a name.
- Select the integration in Einstellungen, Lokale Einstellungen, Website-Domains, or Seiten. Use the scope reference.
- Select the required consent records. Enabled integrations receive all standard events. The script or vendor container selects the events to use.
- Enter trusted setup without
<script>tags. The source has storefront DOM, cookie, and network access. Keep credentials and customer data out of source. Useruntime.onDisposefor cleanup. - Set Enabled in the sidebar and save the record.
- Test script behavior and SDKs on a published test storefront.
For exact save, update, and consent behavior, use the configuration reference.
Send events with a CMS script
Define public IDs and endpoints as constants at the start of the script. Enter this setup in the integration’s JavaScript field:
const endpoint = 'https://metrics.example.com/events';
const controller = new AbortController();
runtime.onDispose(() => controller.abort());
analytics.subscribe('product_viewed', (event) => {
return fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'omit',
signal: controller.signal,
body: JSON.stringify({
event: event.name,
event_id: event.id,
product_id: event.data.productVariant.product.id,
product_title: event.data.productVariant.product.title,
variant_title: event.data.productVariant.title,
}),
}).then((response) => {
if (!response.ok) throw new Error('Analytics request failed.');
});
});The destination must accept cross-origin JSON requests from the storefront. Browser network, CORS, and Content Security Policy rules apply. Trusted scripts do not provide a network sandbox. The host controls API subscriptions and cleanup. Vendor libraries can install their own listeners or requests.
Verify the integration
- Enable and save the integration on the published test storefront.
- Deny its required consent. Make sure the integration does not deliver events.
- Grant the required consent and trigger an event that the script consumes.
- Inspect the destination to confirm receipt.
- Use
window.hitoApp.integrations.inspect()to inspect runtime diagnostics. - Withdraw consent. Make sure event delivery stops and registered cleanup runs.
A delivered diagnostic confirms forwarding to a subscriber. It does not prove that the destination stored the event.
The API reference defines diagnostic contents.
Prepare production
Keep credentials and customer data out of source. Integration URLs are public. Use one installation per destination.
For additional protection, test a storefront CSP in report-only mode before you restrict script and connection origins. Pin vendor SDK versions. Use Subresource Integrity for stable files where supported. An integrity hash on a changing integration URL blocks source updates until page metadata changes. Review analytics permissions and source changes before enabling scripts.
For vendor setup, use Google Tag Manager, direct GA4, or Shopify analytics.