Analytics Config
Per-agent, per-channel analyticsConfig — delivery mode, event mapping, consent, and provider connections.
Analytics is configured per agent, per channel. The analyticsConfig object lives on your agent configuration and is keyed by channel (web | ios | android). This lets web, iOS, and Android use different delivery modes, event names, and on/off states under one agent.
Shape
analyticsConfig: {
enabled: boolean;
requireConsent?: boolean;
channels: {
web?: ChannelAnalyticsConfig;
ios?: ChannelAnalyticsConfig;
android?: ChannelAnalyticsConfig;
};
}
interface ChannelAnalyticsConfig {
enabled: boolean;
deliveryMode: "datalayer" | "native_bridge";
eventMap: {
loops_ai_view_item_list: string;
loops_ai_select_item: string;
};
searchSourceValue: string;
itemListId: string;
provider?: "google_analytics";
measurementId?: string;
providers?: Array<{
type: "mixpanel" | "segment" | "amplitude" | "webhook";
endpoint?: string;
}>;
}Key fields
enabled (agent level)
Master on/off switch. When false, no events are dispatched regardless of channel settings.
requireConsent
When true, the default consent posture is denied until the host CMP explicitly grants it via setAnalyticsConsent("granted"). Default false — posture starts as granted (no regression for existing deployments).
channels
Each channel block is independent. A channel not present in channels is off. The channel field in each emitted event selects which block governs delivery.
deliveryMode
"datalayer"— thewebchannel. Events are pushed towindow.dataLayer."native_bridge"— theiosandandroidchannels. Events cross the SDK bridge to your native app.
eventMap
Maps canonical event names to the labels pushed to the destination. Defaults follow GA4 standard ecommerce names (view_item_list, select_item) — your existing GTM triggers work without any changes.
Customer-interaction events
Alongside the two canonical ecommerce events, the channel also emits flat customer-interaction events that describe the chat and widget funnel: loops_ai_widget_opened, loops_ai_chat_started, loops_ai_message_sent, loops_ai_product_clicked, loops_ai_product_viewed, and loops_ai_search_clicked. Unlike ecommerce events, these carry no ecommerce block.
These are opt-in per event on the channel — the same customer-events concept used on the web channel now also applies to the ios and android channels, where they cross the SDK native bridge and surface through the SDK analytics callback (onAnalyticsEvent / didEmitAnalyticsEvent). Only the events you enable are dispatched, and they pass through the same consent gate as ecommerce events. See the mobile SDK analytics pages (iOS, Android) for how to read them on the host via payload.kind.
provider + measurementId
Set automatically when you complete the Google Analytics connect flow. provider: "google_analytics" + measurementId: "G-XXXX" are written by the dashboard — do not set these manually.
providers (client-side adapters)
An optional list of additional client-side delivery targets, in addition to the always-on Loops AI sink and the dataLayer push. Each adapter fires only if the matching browser SDK is present on the page.
| Type | Fires when |
|---|---|
"mixpanel" | mixpanel is present in the page. |
"segment" | analytics (Segment) is present in the page. |
"amplitude" | amplitude is present in the page. |
"webhook" | Always fires (requires endpoint). |
Consent gate
A single consent gate runs before any adapter sends, including the always-on Loops AI sink. A denied consent stops all events.
// called by the host CMP or your own consent banner
LoopsAI.setAnalyticsConsent("granted"); // or "denied"When requireConsent is false (the default), the posture starts as granted. Set requireConsent: true for agents where you manage consent explicitly — the widget will not fire any event until the host grants consent.
PII sanitisation (email/phone redaction, length caps) runs in the core dispatcher regardless of consent state and cannot be disabled.