Google Analytics 4 (GA4)
Track Octocom chat widget interactions in Google Analytics 4. Works automatically with gtag.js or via Google Tag Manager with a simple trigger setup.
The Octocom chat widget automatically sends events when visitors interact with it. How you receive these events in GA4 depends on how Google Analytics is installed on your site.
Which setup do you have?
There are two common ways to install Google Analytics 4:
| Method | How to identify | Setup required |
|---|---|---|
| gtag.js (direct) | You have a gtag.js script snippet on your site | None — events appear automatically |
| Google Tag Manager (GTM) | You have a GTM container script on your site | You need to create triggers and tags in GTM |
Not sure which one you have? Open your browser's developer console on your site and run:
// Check for gtag.js (direct)
!!document.querySelector('script[src*="gtag/js?id=G-"]');
// true = gtag.js is installed → events work automatically
// Check for GTM
!!document.querySelector('script[src*="gtm.js?id=GTM-"]');
// true = GTM is installed → you need to set up triggersYou can also check your site's HTML source directly:
- Script loading from
googletagmanager.com/gtag/js?id=G-XXXXXX→ gtag.js - Script loading from
googletagmanager.com/gtm.js?id=GTM-XXXXXX→ GTM
What if I have both?
Some sites have both gtag.js and GTM installed. In this case:
- If the
gtag.jssnippet is configured with the GA4 property where you want to see chatbot events, you're all set — events are sent directly to that property via gtag.js. No further action needed. - The events are also pushed to the
dataLayer, so they're available in GTM as well. This means you can additionally route them to other GA4 properties, Facebook Pixel, or any other tag through GTM triggers. - If the
gtag.jssnippet points to a different GA4 property (not the one you want chatbot events in), follow the GTM setup in Option B below to forward events to the correct property.
Option A: gtag.js (automatic)
No setup required. The chat widget detects gtag.js on your page and sends events directly to GA4.
The following events will appear in your GA4 property automatically under Reports > Engagement > Events:
| Event name | When it fires |
|---|---|
octocom_chat_open | Visitor opens the chat widget |
octocom_chat_close | Visitor closes the chat widget |
octocom_chat_message_sent | Visitor sends a message |
All events include the parameter event_category: "Octocom Chat Widget".
That's it — no configuration needed.
Note: Events can take 24–48 hours to appear in standard GA4 reports. To verify events are working immediately, check Reports > Realtime — events will show up there within seconds.
Skip to Using events in GA4 for reporting tips.
Option B: Google Tag Manager
If your GA4 is managed through GTM, you need to create triggers and tags to forward the chat widget events to GA4.
How it works
The chat widget pushes events to window.dataLayer in this format:
window.dataLayer.push({
event: "UserAction",
eventCategory: "Octocom Chat Widget",
eventAction: "Open", // or "Close" / "Send Message"
});GTM can listen for these events and forward them to GA4 (or any other tag like Facebook Pixel, LinkedIn, etc.).
Events reference
| eventAction | Description | When it fires |
|---|---|---|
Open | Chat window opened | User clicks the launcher or chat opens programmatically |
Close | Chat window closed | User clicks the close button |
Send Message | Message sent | Any user message (first and subsequent) |
Step 1: Create Data Layer Variables
In GTM, create two Data Layer Variables so you can use the event data in your tags:
- Go to Variables > New > Data Layer Variable
- Create
eventCategory— Data Layer Variable Name:eventCategory - Create
eventAction— Data Layer Variable Name:eventAction
Step 2: Create triggers
Create one trigger per event (or a single trigger for all).
Example: Trigger for "Chat Open"
- Go to Triggers > New
- Name:
Octocom – Chat Open - Trigger type: Custom Event
- Event name:
UserAction - Fire on: Some Custom Events with conditions:
eventCategoryequalsOctocom Chat WidgeteventActionequalsOpen
Repeat for:
Octocom – Chat Close(eventAction =Close)Octocom – Send Message(eventAction =Send Message)
Step 3: Create GA4 Event tags
Example: GA4 tag for "chat_open"
- Go to Tags > New
- Name:
GA4 – chat_open (Octocom) - Tag type: Google Analytics: GA4 Event
- Select your GA4 Configuration tag
- Event name:
chat_open - (Optional) Add event parameters:
chat_category={{eventCategory}}chat_action={{eventAction}}
- Trigger:
Octocom – Chat Open
Repeat for:
GA4 – chat_close→ event namechat_close, triggerOctocom – Chat CloseGA4 – chat_message_sent→ event namechat_message_sent, triggerOctocom – Send Message
Step 4: Publish
Publish your GTM container. Events will start flowing to GA4.
Register the chatbot user property
The Octocom widget automatically sets a user property called octocom_chatted on visitors who send a message. This property persists across sessions, enabling you to compare conversion rates and revenue between users who engaged with the chatbot and those who didn't.
For GA4 to make this property available in reports and the API, you need to register it as a custom dimension (one-time setup):
- In Google Analytics, go to Admin > Custom definitions > Custom dimensions
- Click Create custom dimension
- Configure it as follows:
- Dimension name:
Octocom Chatted - Scope: User
- User property:
octocom_chatted
- Dimension name:
- Click Save
Note: It can take 24–48 hours for the custom dimension to start appearing in reports after registration. Data will begin populating from the point of registration — it is not applied retroactively.
Using events in GA4
Once events are flowing (either automatically via gtag.js or through your GTM setup), here's how to use them.
Track chat engagement
- Go to Reports > Engagement > Events to see event counts
- Example metric: Chat Engagement Rate = (Chat Opens / Page Views) x 100
- Break down by page, device, or traffic source
Build a conversation funnel
Use Explore > Funnel exploration:
- Step 1 —
chat_open(oroctocom_chat_openfor gtag.js) - Step 2 —
chat_message_sent(oroctocom_chat_message_sent) - Step 3 — Your main conversion (purchase, lead submission, etc.)
This shows drop-off between opening chat, engaging, and converting.
Mark as conversion
If you treat chat engagement as a micro-conversion:
- Go to Configure > Events
- Find your chat event
- Toggle Mark as conversion
Custom reports
Example dimensions to combine with chat events:
- Page URL — which pages drive the most chat interactions
- Traffic source — which channels (Google Ads, social, email) engage most with chat
- Device — desktop vs. mobile chat usage
Use Explore > Free form with eventName, pageLocation, sessionSourceMedium as dimensions.
Using events for other tags in GTM
If you're using GTM, you can reuse the same triggers to fire additional tags:
- Facebook Pixel / Meta — fire a
Leadevent whenSend Messagefires - LinkedIn Insight Tag — create a custom conversion for chat engagement
- Remarketing — build audiences of users who opened chat but didn't send a message
Revenue attribution (optional)
Connect your GA4 property to Octocom to automatically measure the revenue impact of chatbot conversations. Once connected, Octocom syncs your conversion data and correlates it with chatbot usage — so you can see exactly how much revenue is influenced by chat interactions.
No code required. This takes about 2 minutes.
How to connect
-
Open Google Analytics and make sure the correct property is selected at the top (the one that tracks your website/checkout)
-
Click Admin (gear icon in the bottom-left)
-
Under your property settings, click Property access management
-
Click the + button in the top-right corner and select Add users
-
Enter the following email address:
-
Set the role to Analyst (read-only access, includes revenue data)
-
Click Add
That's it. Octocom will automatically detect the connection and begin syncing your conversion data.
What Octocom can see
With Analyst access, Octocom can only read your analytics data (including revenue metrics). We cannot modify your GA4 property, create events, change settings, or access any personal information. The data we access includes:
- Conversion events (purchases, revenue)
- Session-level engagement metrics
- Traffic source data
This allows us to correlate chatbot sessions with downstream conversions and surface insights like:
- Revenue from sessions where the chatbot was used vs. not used
- Conversion rate uplift from chat-engaged visitors
- Which chatbot conversations lead to the highest order values
What if I don't have GA4 ecommerce tracking?
For revenue attribution to work, your GA4 property needs to be receiving ecommerce events (like purchase). To check, go to Reports > Monetization > Ecommerce purchases in GA4 — if you see data there, you're all set.
Shopify stores: Ecommerce tracking is typically enabled by default through Shopify's built-in GA4 integration. If you don't see purchase data in GA4, make sure GA4 is connected in your Shopify admin under Online Store > Preferences.
Other platforms (WooCommerce, Magento, custom, etc.): Ecommerce tracking needs to be set up manually or through a plugin. Your platform may offer a GA4 integration — check your platform's documentation for "GA4 ecommerce" setup. If you have a custom checkout, your development team will need to implement the GA4 ecommerce events (specifically the purchase event).
Technical notes
- Events are sent automatically by the Octocom chat widget — no code changes needed on your site
- For gtag.js: events are sent via
window.gtag()if present - For GTM: events are pushed to
window.dataLayer - Debug mode: events are logged to the browser console (useful for verifying during setup)