Custom Integrations

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:

MethodHow to identifySetup required
gtag.js (direct)You have a gtag.js script snippet on your siteNone — events appear automatically
Google Tag Manager (GTM)You have a GTM container script on your siteYou 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 triggers

You can also check your site's HTML source directly:

  • Script loading from googletagmanager.com/gtag/js?id=G-XXXXXXgtag.js
  • Script loading from googletagmanager.com/gtm.js?id=GTM-XXXXXXGTM

What if I have both?

Some sites have both gtag.js and GTM installed. In this case:

  • If the gtag.js snippet 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.js snippet 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 nameWhen it fires
octocom_chat_openVisitor opens the chat widget
octocom_chat_closeVisitor closes the chat widget
octocom_chat_message_sentVisitor 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

eventActionDescriptionWhen it fires
OpenChat window openedUser clicks the launcher or chat opens programmatically
CloseChat window closedUser clicks the close button
Send MessageMessage sentAny 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:

  1. Go to Variables > New > Data Layer Variable
  2. Create eventCategory — Data Layer Variable Name: eventCategory
  3. 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"

  1. Go to Triggers > New
  2. Name: Octocom – Chat Open
  3. Trigger type: Custom Event
  4. Event name: UserAction
  5. Fire on: Some Custom Events with conditions:
    • eventCategory equals Octocom Chat Widget
    • eventAction equals Open

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"

  1. Go to Tags > New
  2. Name: GA4 – chat_open (Octocom)
  3. Tag type: Google Analytics: GA4 Event
  4. Select your GA4 Configuration tag
  5. Event name: chat_open
  6. (Optional) Add event parameters:
    • chat_category = {{eventCategory}}
    • chat_action = {{eventAction}}
  7. Trigger: Octocom – Chat Open

Repeat for:

  • GA4 – chat_close → event name chat_close, trigger Octocom – Chat Close
  • GA4 – chat_message_sent → event name chat_message_sent, trigger Octocom – 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):

  1. In Google Analytics, go to Admin > Custom definitions > Custom dimensions
  2. Click Create custom dimension
  3. Configure it as follows:
    • Dimension name: Octocom Chatted
    • Scope: User
    • User property: octocom_chatted
  4. 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:

  1. Step 1 — chat_open (or octocom_chat_open for gtag.js)
  2. Step 2 — chat_message_sent (or octocom_chat_message_sent)
  3. 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:

  1. Go to Configure > Events
  2. Find your chat event
  3. 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 Lead event when Send Message fires
  • 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

  1. Open Google Analytics and make sure the correct property is selected at the top (the one that tracks your website/checkout)

  2. Click Admin (gear icon in the bottom-left)

  3. Under your property settings, click Property access management

  4. Click the + button in the top-right corner and select Add users

  5. Enter the following email address:

  6. Set the role to Analyst (read-only access, includes revenue data)

  7. 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)

On this page