Help

Overview Admin Chat UI Design Curated Answers Search Settings Conversational Intelligence Data Sync Upload Documents Human Handoff Admin Console Authorisation Contact Support

Website Integration Gtm Analytics

Airgentic Help

Google Tag Manager (GTM) Analytics

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.


Prerequisites

  1. Airgentic script tag on your website — see Website Integration Script Tag.
  2. Google Tag Manager installed on the same pages (typically in <head> or just after the opening <body> tag).
  3. GTM dataLayer tracking enabled for your service in the admin console (see below).

Enable in the Admin Console

Open Service ConfigurationAnalytics 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.


How It Works

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.


Event Schema

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
}

Tracked Actions (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).


GTM Setup (Customer Side)

These steps are performed in your GTM container, not in Airgentic:

  1. Create a Custom Event trigger with event name chatbot.
  2. Create Data Layer Variables for the fields you need (e.g. chat_action, session_id, chat_question).
  3. Create a GA4 Event tag (or other tag) that fires on the chatbot trigger and maps variables to your analytics parameters.
  4. Publish the container and verify events in GTM Preview mode or GA4 DebugView.

Verifying Events

  1. Enable GTM dataLayer tracking for your service in the admin console.
  2. Open your website with the chat widget and browser DevTools.
  3. Inspect window.dataLayer after interacting with the widget.
  4. Look for console log lines prefixed with dataLayer add: (diagnostic output from the Airgentic loader).

Privacy Notes

  • Metadata-only tracking (widget opens, message counts, citation clicks, ratings) does not include question or answer text.
  • Include question and answer text is a separate opt-in because message content may contain personal or sensitive information.
  • Review your privacy policy and consent mechanisms before enabling conversational data for production traffic.

You have unsaved changes