Airgentic Help
Track chatbot interactions in your existing site analytics stack by pushing structured events to window.dataLayer. Your marketing or analytics team can then use standard Google Tag Manager workflows to forward those events into GA4 or any other platform connected to GTM.
Airgentic does not call GA4 APIs directly. The widget writes events to the host page's dataLayer, and GTM handles the rest.
<head> or just after the opening <body> tag).Open Service Configuration → Analytics tab:
| Setting | Description |
|---|---|
| Enable GTM dataLayer tracking | Turns on structured chatbot events pushed to window.dataLayer on your website. |
| Include question and answer text | Privacy-sensitive opt-in. When enabled, user questions and assistant answers are included in analytics events. Requires GTM tracking to be enabled. |
Both settings are stored in your service configuration (analytics.gtm_data_layer_enabled and analytics.gtm_include_conversation_data). They default to off for new services.
User interacts with chat widget (iframe)
↓
Widget sends analytics_event via postMessage to parent page
↓
Airgentic parent script pushes normalized event to window.dataLayer
↓
Your GTM container triggers tags (e.g. GA4 event tag)
The widget runs inside an iframe for security and styling isolation. Because GTM lives on the host page, Airgentic bridges iframe events to the parent dataLayer automatically when tracking is enabled.
Every event pushed to dataLayer uses a consistent shape:
| Field | Value | Notes |
|---|---|---|
event |
"chatbot" |
Use this as your GTM Custom Event trigger name. |
chat_source |
"Airgentic" |
Identifies the source system. |
chatbot_id |
Script version (e.g. "1.4") |
From the ?v= parameter on the Airgentic loader script. |
chat_action |
Action name | See table below. |
session_id |
Airgentic session ID | Present once a session is established. |
| Other fields | null or event-specific values |
All fields are present on every event for GA4 schema stability. |
When Include question and answer text is enabled, these fields may also contain values:
| Field | Used by |
|---|---|
chat_question |
user_message_sent |
chat_answer |
assistant_response |
Example event (metadata only):
{
event: "chatbot",
chat_source: "Airgentic",
chatbot_id: "1.4",
chat_action: "user_message_sent",
session_id: "abc123",
chat_type: null,
chat_link_text: null,
chat_link_url: null,
chat_value: null,
chat_completeness: null,
link_url: null,
link_text: null,
chat_question: null,
chat_answer: null
}
chat_action)chat_action |
When it fires |
|---|---|
chat_widget_opened |
User opens the hover chat widget (not fired for always-visible Service Hub). |
chat_widget_closed |
User closes the hover chat widget. |
user_message_sent |
User submits a text or voice message. |
assistant_response |
Assistant finishes streaming a response. |
citation_clicked |
User clicks a citation/source link. |
information_link_clicked |
User clicks a non-citation link in a response (e.g. privacy policy). |
thumbs_up |
User clicks the thumbs-up rating. |
thumbs_down |
User clicks the thumbs-down rating. |
billable |
Server marks the interaction as billable. |
answer_completeness |
Server reports answer completeness classification. |
Citation clicks include chat_link_url and chat_link_text. Information link clicks include link_url and link_text. Widget open/close events include chat_type (hover_widget or service_hub).
These steps are performed in your GTM container, not in Airgentic:
chatbot.chat_action, session_id, chat_question).chatbot trigger and maps variables to your analytics parameters.window.dataLayer after interacting with the widget.dataLayer add: (diagnostic output from the Airgentic loader).