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 pageWhat to do
Sends a Google Analytics purchase eventOption A: Use your Google Analytics event. You may not need to change anything.
Sends no purchase event, or one with other field namesOption 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

FieldNeededWhat it is
order_idAlwaysYour order number, as text or a number.
valueTo count as a saleThe order total, as a number or text, like 1249.50. A decimal comma, like '1.249,50', is ignored.
currencyTo count as a saleThe three-letter currency code, like DKK.
itemsTo match productsOne entry per product bought, with the fields below.
variant_idIn each itemThe product id from your product feed. It is the same id the chat passes to your add-to-cart handler.
product_idIf no variant_idUsed when there is no variant_id.
name, quantity, priceOptionalThe product name, how many, and the price of one item.

Test it

  1. Start a chat

    Open the chat on your shop and send a message.

  2. Place a test order

    Use the same browser, and stay on the order confirmation page.

  3. Check the browser console

    With Option A, run dataLayer and find the entry with your order id. With Option B, a warning starting with Zuzana: says which field could not be used.

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

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