How to track chats in Google Analytics and other tools
The chat widget pushes its events to window.dataLayer on your store page. Google Tag Manager reads them there and sends them to GA4, Mixpanel or any other tool it is connected to. In that tool you can compare the visitors who chatted with all visitors: their purchases, revenue and conversion rate, for each of your stores.
There is no setting. The events are always pushed, and a store without Google Tag Manager or another tool that reads dataLayer sees no change. When the page has no dataLayer yet, the widget creates it, the same way Google Tag Manager does.
Events
| Event | When |
|---|---|
echat_open | The visitor opens the chat window: with the chat button, the unread message preview, or $echat.window.open() (see JavaScript API). A chat that is still open when the visitor moves to the next page is not counted again, and a chat embedded in a page has no opening to count. |
echat_conversation_start | The visitor sends the first message of a conversation. |
echat_message | The visitor sends a message, the first one included. |
echat_product_click | The visitor clicks a product card in the chat. |
Each event has these fields:
| Field | In | Value |
|---|---|---|
echat_conversation_id | All events, when there is a conversation | eChat's ID of the conversation. All events of one conversation carry the same ID. |
echat_product_name | echat_product_click | The product name on the card. |
echat_product_sku | echat_product_click, when the card has one | The product SKU. |
echat_product_price | echat_product_click, when the card shows a price | The price as a number. For a product shown "from" a price, that price. |
echat_product_currency | echat_product_click | The currency code, for example USD. |
echat_product_url | echat_product_click | The product page URL. |
No event contains the text of a message, or the visitor's name or email.
If you hold the widget back until the visitor accepts cookies (see Cookie consent), there are no events before that either: the widget is not on the page yet.
Example: chats and sales in GA4
This example sends the events to GA4 through Google Tag Manager, then compares the visitors who started a conversation with all visitors. It assumes your store already sends its purchases to GA4.
1. Send the events to GA4
In Google Tag Manager:
- Under Variables, add a Data Layer Variable for each field you want in GA4, for example
echat_conversation_id,echat_product_nameandechat_product_price. - Under Triggers, add a Custom Event trigger with the event name
echat_.*and Use regex matching on. - Under Tags, add a Google Analytics: GA4 Event tag with your measurement ID, the event name
{{Event}}, and the variables above as event parameters. Fire it on the trigger above. - Submit the container.
Check it in Preview: open the chat on your store and send a message. echat_open, echat_conversation_start and echat_message appear in the event list.
To use an event parameter such as echat_product_name in GA4 reports, register it in GA4 under Admin > Custom definitions as an event-scoped custom dimension.
2. Compare the visitors who chatted
In GA4, go to Explore and open a Free form exploration:
- Add a user segment: users who had the event
echat_conversation_start. Name it, for example,Chatted. - Add the dimension Hostname, and the metrics Total users, Ecommerce purchases, Purchase revenue and User conversion rate.
- Put Hostname in the rows, and both the
Chattedsegment and All users in Segment comparisons.
Each row now shows, for one store, how many visitors chatted, what they bought, and how that compares with all visitors. Change the date range to follow it over time.
GA4 can take a day to show new events in explorations. Use Realtime or DebugView to see them come in right away.