Embed the widget
Events for GA4 & Tag Manager
The chat can report what visitors do inside it to the analytics you already run — Google Tag Manager, a direct GA4 tag, or anything else listening for browser events. Turn it on per agent under Customize → Analytics events; it is off until you do.
How the events arrive
The widget runs inside your page, not in an iframe, so it hands events straight to whatever your site already loads. Three destinations, each independent — a broken one cannot stop the others, and none of them can break the chat:
window.dataLayer— Google Tag Manager. This is the one most sites want: build the GA4 event, the conversion and the funnel in GTM without touching code.window.gtag— a direct GA4 tag with no tag manager in between.- A DOM event on
window, always, with the same name. Use it for Plausible, Matomo, or your own listener:window.addEventListener('blengi_chat_started', e => console.log(e.detail)).
The events
Each name is prefixed with the value you set (default
blengi_) so one GTM trigger can select all of them.
| Event | Fires when |
|---|---|
chat_opened | The chat panel opens, however it was opened. |
chat_started | The visitor's first message of a conversation — the moment a passer-by became a conversation. |
message_sent | Every visitor message, including the first. Use it for conversation depth. |
cta_clicked | A call-to-action button in the chat is clicked. |
product_clicked | A product card's link is followed. |
lead_form_opened | The lead form appears, from any of its triggers. |
lead_form_submitted | The lead was accepted by the server — not merely that Send was pressed. |
human_takeover_requested | The visitor asked for a person. Fires on the request, whether or not anyone picks up: what a funnel wants to show is how often the AI ran out of road. |
Parameters
Every event carries agent_id, agent_name,
page_url and page_path — the page read at
the moment the event fires, so a single-page app that navigates under
the widget still reports the right one. On top of that:
chat_started,message_sent,human_takeover_requested—conversation_id.message_sent—message_length, a character count. Never the message.cta_clicked—cta_label,cta_type,cta_url.product_clicked—product_title,product_url.lead_form_submitted—fields_submitted, a count of the fields filled in.
What is never sent
Consent
Consent is deliberately not our decision. We push into the page's own tag layer, and your existing cookie banner — Google Consent Mode, or whatever your site runs — decides whether anything is sent onward, exactly as it does for every other tag on the page. Holding a second, competing consent state inside the chat would be one you could neither see nor audit, and it would disagree with your banner sooner or later.
Setting it up in Tag Manager
- Switch on Customize → Analytics events for the agent, and note the prefix.
- In GTM, create a Custom Event trigger. To catch
everything at once, set the event name to
blengi_.*and tick use regex matching. - Add a GA4 Event tag on that trigger, with the
event name set to
{{Event}}. - For each parameter you want in GA4, add a Data Layer Variable
(
agent_name,cta_type, and so on) and map it in the tag's event-parameter list. - Preview, open the chat on your site, and confirm the events
appear. Then mark the ones that matter — usually
lead_form_submitted— as conversions in GA4.
A quick check without GTM: open the browser console on your site and
run
window.addEventListener('blengi_chat_opened', e => console.log(e.detail)),
then open the chat.