Step 1: Track sales
Chat Revenue learns about an order on your order confirmation page. There are two ways to set that up.
| Your order confirmation page | What to do |
|---|---|
| Sends a Google Analytics purchase event | Option A: Use your Google Analytics event. You may not need to change anything. |
| Sends no purchase event, or one with other field names | Option B: Add the tracking script |
Option A: Use your Google Analytics event
The chat reads purchase events from window.dataLayer by itself. The event needs the order id, the total and the currency, and each item_id must be the product id from your product feed:
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'ORDER-1001',
value: 1249.50,
currency: 'DKK',
items: [{ item_id: '471426', quantity: 5, price: 249.90 }]
}
});A gtag('event', 'purchase', …) call with the same fields works too, and so does Universal Analytics enhanced ecommerce.
Does your event use other field names? Don't push a second purchase event, because your own analytics tags may count every order twice. Use Option B instead.
Option B: Add the tracking script
Add this to your order confirmation page, filled in with the order's real values. The last lines wait for the chat script, in case your page runs this first.
<script>
(function () {
var order = {
order_id: 'ORDER-1001',
value: 1249.50,
currency: 'DKK',
items: [
{ variant_id: '471426', name: 'Barolo 2019', quantity: 5, price: 249.90 }
]
};
function send() {
window.Zuzana.track.purchase(order);
}
if (window.Zuzana) {
send();
} else {
window.addEventListener('zuzana-loaded', send, { once: true });
}
})();
</script>Each order is sent once per browser, so reloading the page is safe.
What to send
| Field | Needed | What it is |
|---|---|---|
order_id | Always | Your order number, as text or a number. |
value | To count as a sale | The order total, as a number or text, like 1249.50. A decimal comma, like '1.249,50', is ignored. |
currency | To count as a sale | The three-letter currency code, like DKK. |
items | To match products | One entry per product bought, with the fields below. |
variant_id | In each item | The product id from your product feed. It is the same id the chat passes to your add-to-cart handler. |
product_id | If no variant_id | Used when there is no variant_id. |
name, quantity, price | Optional | The product name, how many, and the price of one item. |
Test it
Start a chat
Open the chat on your shop and send a message.
Place a test order
Use the same browser, and stay on the order confirmation page.
Check the browser console
With Option A, run
dataLayerand find the entry with your order id. With Option B, a warning starting with Zuzana: says which field could not be used.Look in Chat Revenue
The order shows up within about 30 minutes.
What the tracking script returns
To see the result while you test, change send to console.log(window.Zuzana.track.purchase(order));.
| Result | What it means |
|---|---|
'reported' | The customer chatted in this browser, and the order is sent to Zuzana. |
'no_chat' | The customer hasn't chatted in this browser, so nothing is sent. |
'duplicate' | This order was already sent from this browser. |
'invalid' | The order has no usable order_id. |
Did this answer your question?