Revenue attribution with GA4
Send chat events to Google Analytics 4 and compare revenue from shoppers who chatted with those who didn't.
The Octocom chat widget reports chat activity to Google Analytics 4, or GA4, and marks every visitor who sends a message. That shows you what your chat is worth, in two ways:
- Chat engagement in GA4. See how many visitors open the chat and send messages, and build funnels from chat to purchase, alongside the rest of your traffic.
- Revenue attribution in Octocom. Connect your GA4 property to Octocom to compare revenue, order value and conversion between shoppers who chatted and shoppers who didn't, in Metrics -> Sales.
Setup takes three steps:
- Make sure the widget's events reach GA4. With gtag.js this is automatic. With Google Tag Manager, add a few triggers and tags.
- Register the
octocom_chatteduser property as a custom dimension in GA4. - Optionally, connect GA4 to Octocom to see the revenue split in your Octocom metrics.
GA4 and Octocom's own purchase tracking
Octocom also records purchases itself and links each one to the visitor who chatted: automatically for Shopify stores, and through browser session purchases for any other checkout, counting purchases within 7 days of a conversation. GA4 instead compares shoppers who ever chatted with those who didn't, so its totals run higher. When Octocom has no attributed revenue of its own for a view, Metrics -> Sales shows GA4's revenue instead.
Which setup do you have?
There are two common ways to install GA4:
| 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 | 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:
- A script loading from
googletagmanager.com/gtag/js?id=G-XXXXXXmeans gtag.js. - A script loading from
googletagmanager.com/gtm.js?id=GTM-XXXXXXmeans GTM.
What if I have both?
The widget sends each event one way, never both. If the page loads gtag.js for a GA4 property (a gtag/js?id=G- script and the gtag function), it sends the Option A events through gtag. Otherwise it pushes the Option B events to the dataLayer for GTM.
- If gtag.js on the page is configured with the GA4 property where you want chat events, you're all set. Events go to the properties configured in gtag.js.
- If you want the events in a GA4 property that gtag.js on the page doesn't send to, add that property to your gtag.js or Google tag configuration.
- GTM triggers on the
UserActionevent (Option B) don't fire on pages with gtag.js, because the widget sends through gtag there instead.
Option A: gtag.js (automatic)
No setup required. The chat widget detects gtag.js on your page and sends events directly to GA4.
These events appear in your GA4 property 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".
Checking that events arrive
Events can take 24 to 48 hours to appear in standard GA4 reports. Open Reports -> Realtime to see them within seconds.
Next, register the chat user property.
Option B: Google Tag Manager
If GA4 is managed through GTM, create triggers and tags that forward the chat widget's 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"
});The widget pushes these events when the page has no gtag.js for a GA4 property. GTM can listen for them and forward them to GA4, or to any other tag such as the Meta Pixel or LinkedIn.
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) |
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
eventCategorywith Data Layer Variable NameeventCategory. - Create
eventActionwith Data Layer Variable NameeventAction.
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 the conditions:
eventCategoryequalsOctocom Chat WidgeteventActionequalsOpen
Repeat for:
Octocom - Chat Close(eventAction =Close)Octocom - Send Message(eventAction =Send Message)
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
- Measurement ID: your GA4 measurement ID (
G-XXXXXXX). - Event name:
chat_open - Optionally, 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
Forward the chat user property
Besides the three events above, the widget pushes a separate dataLayer event when a visitor first sends a message:
window.dataLayer.push({
event: "octocom_user_property",
octocom_chatted: "true",
});This sets a user property (not an event parameter) called octocom_chatted. It persists across sessions and is what revenue attribution uses to separate shoppers who chatted from those who didn't. Without this step, the custom dimension you register below stays empty.
-
Add a Data Layer Variable for the property value:
- Variables -> New -> Data Layer Variable
- Name:
octocom_chatted - Data Layer Variable Name:
octocom_chatted
-
Add a trigger for the user-property push:
- Triggers -> New
- Name:
Octocom - User Property - Trigger type: Custom Event
- Event name:
octocom_user_property - Fire on: All Custom Events
-
Add a GA4 Event tag that sets the user property:
- Tags -> New
- Name:
GA4 - octocom_chatted (Octocom) - Tag type: Google Analytics: GA4 Event
- Measurement ID: your GA4 measurement ID (
G-XXXXXXX). - Event name:
octocom_user_property(any name works; this tag exists to carry the user property) - Under User Properties, add
octocom_chatted={{octocom_chatted}} - Trigger:
Octocom - User Property
Publish
Publish your GTM container. Events and the user property start flowing to GA4.
Register the chat user property
The widget sets a user property called octocom_chatted on visitors who send a message. It persists across sessions, so you can compare conversion rates and revenue between visitors who used the chat and those who didn't.
GTM users
The widget pushes the property into the dataLayer, but it only reaches GA4
once you complete Forward the chat user
property in Option B. Registering the custom
dimension alone is not enough.
For GA4 to make the property available in reports and to Octocom, register it as a custom dimension (a one-time setup):
- In Google Analytics, go to Admin -> Custom definitions -> Custom dimensions.
- Click Create custom dimension.
- Configure it:
- Dimension name:
Octocom Chatted - Scope: User
- User property:
octocom_chatted
- Dimension name:
- Click Save.
Not retroactive
The custom dimension can take 24 to 48 hours to appear in reports. Data is collected from the moment you register it, not before.
Connect GA4 to Octocom
Connecting your GA4 property lets Octocom read your revenue data and show it in Metrics -> Sales, split between shoppers who chatted and shoppers who didn't. No code is required.
Before you start: your GA4 property must receive ecommerce purchase events (see below), and the octocom_chatted custom dimension must be registered.
Give Octocom read access in GA4
-
Open Google Analytics and select the property that tracks your website and checkout.
-
Click Admin (the gear icon in the bottom left).
-
Under your property settings, click Property access management.
-
Click + in the top right corner and select Add users.
-
Enter this email address:
octocom-ga4-reader@octocom.iam.gserviceaccount.com -
Set the role to Analyst. The Viewer role can't read revenue metrics.
-
Click Add.
Find your GA4 Property ID
In GA4, go to Admin -> Property settings and copy the numeric Property ID, for example 251601386. This is not the G-XXXXXXX measurement ID.
Connect it in Octocom
In Octocom, open Settings -> Workspace -> Integrations -> Google Analytics 4, paste the number into GA4 Property ID and click Connect.
Octocom tests the connection before saving and tells you exactly what to fix if something is missing: the property ID can't be found, the service account has no access or only the Viewer role, or the octocom_chatted dimension isn't registered. Right after setup it may report that it is connected but hasn't seen any visitors who chatted yet. Revenue appears once shoppers chat and the widget reports them.
What Octocom reads
With Analyst access, Octocom runs read-only reports on your property. It reads daily totals of users, purchasers, purchase revenue and transactions, split by whether the visitor chatted (octocom_chatted). It does not read data about individual visitors, and it does not change your property's settings, events or tags.
Octocom refreshes these numbers every hour for the last 30 days up to yesterday, so purchases that GA4 reports late still correct earlier days. In Metrics -> Sales you can then compare:
- revenue from shoppers who chatted and from those who didn't,
- conversion rate for both groups,
- average order value for both groups.
What if I don't have GA4 ecommerce tracking?
Revenue attribution needs your GA4 property to receive ecommerce events, specifically 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 usually enabled 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 and so on): ecommerce tracking is set up manually or through a plugin. Your platform may offer a GA4 integration: check its documentation for "GA4 ecommerce". With a custom checkout, your development team needs to implement the GA4 ecommerce events, specifically purchase.
Using events in GA4
Once events are flowing, through gtag.js or 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 it down by page, device or traffic source.
Build a conversation funnel
Use Explore -> Funnel exploration:
- Step 1:
chat_open(oroctocom_chat_openwith gtag.js) - Step 2:
chat_message_sent(oroctocom_chat_message_sent) - Step 3: your main conversion (purchase, lead submission and so on)
This shows the drop-off between opening the chat, engaging and converting.
Mark as a key event
If you treat chat engagement as a micro-conversion, mark the chat event as a key event (GA4's name for a conversion):
- Go to Admin -> Data display -> Events.
- Find your chat event.
- Mark it as a key event.
Custom reports
Useful 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 and mobile chat usage.
Use Explore -> Free form with eventName, pageLocation and sessionSourceMedium as dimensions.
Using events for other tags in GTM
With GTM, you can reuse the same triggers to fire other tags:
- Meta Pixel: fire a
Leadevent whenSend Messagefires. - LinkedIn Insight Tag: create a custom conversion for chat engagement.
- Remarketing: build audiences of visitors who opened the chat but didn't send a message.
Technical notes
- The chat widget sends the events automatically. No code changes are needed on your site.
- When the page loads gtag.js for a GA4 property, events are sent through
window.gtag(). Otherwise they are pushed towindow.dataLayer. - The
octocom_chatteduser property is set once per page load, on the visitor's first message. - With the web chat
logLevelset todebug(see Configure the chat widget), the widget logs each event to the browser console, which helps when verifying the setup.