How do I Install Google Analytics 4 Event Tracking?
The LearnWise chat widget now supports event tracking through Google Analytics 4 (GA4). Once installed, you can see exactly how visitors interact with your chat — when they open it, send messages, click links, and more — all inside your existing Google Analytics dashboard.
1 min readUpdated
On this page
What Gets Tracked #
The following events are captured automatically once the tracking script is installed. Note that lw_message_sent, lw_chat_engaged, and lw_chat_link_clicked require an updated version of the LearnWise chat widget to be deployed — without it, these three events will not fire.
| Event Name | When It Fires |
|---|---|
| lw_chat_clicked | User clicks the chat launcher button |
| lw_chat_opened | Chat window opens |
| lw_chat_closed | Chat window closes |
| lw_chat_engaged | User clicks anywhere inside the open chat (fires at most once every 5 seconds) |
| lw_message_sent | User sends a message |
| lw_chat_link_clicked | User clicks a source link in a chat response |
| lw_chat_link_opened | User opens a link in the chat preview modal |
Before You Begin #
You will need either Google Tag Manager (GTM) or a GA4 tracking snippet already installed on your website.
Installation via Google Tag Manager (Recommended) #
This is the easiest method. You do not need to host any files yourself — simply paste the script into your GTM account.
- Go to tagmanager.google.com and open your container
- Navigate to Tags → New → Custom HTML
- Paste the contents of the LearnWise tracking script: LearnWise_GA_Tracking.js
- Under Triggering, select All Pages
- Name the tag "LearnWise Chat Tracking"
- Click Submit → Publish
Installation via Script Tag #
If you manage your website code directly, paste the script after your GTM or GA4 snippet and after the LearnWise injector setup. Alternatively, you can paste the script's contents directly into a script tag on your page.
Verifying It Works #
Open your website, interact with the chat widget, then go to GA4 → Reports → Realtime. Events will appear within approximately 20 seconds.
Still stuck?
Ask the LearnWise assistant. It answers from these guides.
Related guides
- Developer Guide: Signed Context InjectionIntegrations
- How do I enable Context Injection in LearnWise?Integrations
- How do I enable SCORM content ingestion in Brightspace?Integrations
- How do I integrate LearnWise with Freshdesk (Native)?Integrations
- How do I integrate LearnWise with Merge ticketing integrations?Integrations