Chat events¶
The widget tells your page when something happens in the chat, so you can count it in your own analytics. Website widget only.
Each event fires twice:
- as a
kothok:eventevent onwindow, for your own code; - as a Google Tag Manager event named
kothok_<name>, when the page has adataLayer.
Events carry ids and amounts only. They never include what the shopper typed or their name, phone or email. For those, use webhooks.
Listen in your code¶
<script>
window.addEventListener("kothok:event", function (e) {
console.log(e.detail.name, e.detail);
});
</script>
Add it before or after the widget script.
Events¶
| Name | When | Fields |
|---|---|---|
chat_opened |
The shopper opens the chat | |
chat_closed |
The shopper closes the chat | |
conversation_started |
The first message of a new conversation is sent | |
product_clicked |
A product card is opened | product_id, title, price, currency |
added_to_cart |
A product is added from a card | product_id, title, price, currency, variant, quantity |
checkout_started |
Checkout is opened from the cart bar or a card | source: cart or card |
order_placed |
An order is placed in the chat | order_ref, total, currency |
lead_captured |
The shopper leaves their contact details | |
handed_to_team |
The chat is passed to your team | |
rated |
The shopper rates the conversation | rating |
A field without a value is left out.
Google Tag Manager¶
In Tag Manager, add a Custom Event trigger with the event name, for example
kothok_order_placed. Read fields with a Data Layer Variable such as kothok.total.
order_placed is its own event, not GA4's purchase. Your shop's thank-you page may already
send purchase, and using both would count an order twice. Track chat orders on
kothok_order_placed, which covers orders placed in the chat, including cash on delivery.