AgentStack Docs

Listen for widget events

Measure and coordinate the embedded chat experience without scraping it.

Widget events let the host page observe supported moments in an embedded conversation. The host page does not read private widget state or scrape rendered messages. Register listeners in the same step that creates the embed. When you remove the page or component, remove the listeners too. This practice avoids duplicate analytics when a single-page app navigates or remounts its chat launcher.

You can use events for host-page concerns. Examples are opening a support panel, recording an interaction in your own analytics system, and adjusting the layout around the widget. Keep the event handler small and resilient. The handler must tolerate repeated notifications, late arrival after navigation, and an unavailable analytics provider. Do not infer answer quality, user identity, or a completed business action from a visual event alone.

To store durable conversation data, get server-side authorization first. Then use the REST API or an approved MCP integration. Widget event payloads are not a substitute for API credentials. The embed must never expose an organization API key in browser JavaScript.