Skip to main content
The chat widget runs inside a cross-origin iframe, so your page cannot read its state directly. Instead, the embed loader exposes a small API on window.anyreach and emits a stream of events: what the visitor did on your site, what they did with the widget, and what happened in the conversation. Every event carries the same envelope (visitor id, session, page, campaign, device), so a single record is joinable into a funnel without lookups. Events are delivered to your own JavaScript callbacks and, optionally, pushed to a Google Tag Manager data layer. Nothing on this page is sent to Anyreach: the page and journey events exist only in your visitor’s browser until your code does something with them.

Quick start

Subscribe before the loader arrives by queueing commands on window.anyreach. The loader replays the queue when it loads, so listeners registered this way see the very first events (session_started, page_viewed, widget_loaded).
After the loader has run, window.anyreach is an object and the same calls work directly:
push([...]) keeps working after load, so a snippet written for the queue form never has to care which state the loader is in.

API

Google Tag Manager

Each event is pushed as { event: 'anyreach.<name>', anyreach: { ...payload } }. In GTM, create a Custom Event trigger on anyreach.widget_opened (or a regex such as anyreach\..*) and read fields with Data Layer Variables like anyreach.page_path or anyreach.conversation_id.

Envelope

Every event carries these fields. Ids are minted by the loader on your page, in first-party storage, so they survive across pages even in browsers that partition third-party iframe storage.

Events

Page and journey

Emitted by the loader on your page; no widget interaction needed. These give you the denominator for every engagement rate. Turn them off with config({ pageEvents: false }) if your consent setup does not cover page-level tracking.

Widget lifecycle

Conversation

Yours

Notes

  • Dedupe on event_id, order on sequence_number. Listeners fire synchronously in the order events happen, but if you forward them to a server, do not trust client clocks for ordering.
  • Only your page sees these events. Anyreach does not receive page or journey data from the loader. Conversation data reaches Anyreach through the widget as it always has. Events are delivered only to the origin the loader embedded the widget from; a widget framed some other way emits nothing.
  • Consent. The page and journey events observe scroll depth, dwell time and URLs. If your consent banner gates that kind of tracking, call config({ pageEvents: false }) until consent is given, or simply do not subscribe.
  • Outcome classification, intent and sentiment are produced server-side after the conversation and are not part of this stream.