Conversions & revenue

Ecommerce & revenue

Attribute real money to the channels and campaigns that earned it. Start in the browser; move to the server for revenue you can fully trust.

Quick start: browser purchase event

On your order-confirmation page, fire a purchase with a value:

window.servoki.track('purchase', {
  value: 49.90,
  currency: 'EUR',
  plan: 'pro'
});

That's enough to see revenue by source, campaign and landing page in the dashboard. The catch: it runs in the browser, so ad-blockers and a closed tab on the thank-you page can cost you conversions.

Track the whole purchase journey

Fire an event at each step a shopper takes. Then you can build a funnel in the dashboard — view_itemadd_to_cartbegin_checkoutpurchase — and see exactly where people drop off, with revenue at every stage. Use these standard names so events group cleanly:

1. Product viewed — someone lands on a product page:

window.servoki.track('view_item', {
  item: 'SKU-204',
  name: 'Merino runner',
  price: 119.00,
  currency: 'EUR'
});

2. Added to cart — the key engagement signal. Fire it on the click, not on a page load, so it counts even on single-page stores:

window.servoki.track('add_to_cart', {
  item: 'SKU-204',
  name: 'Merino runner',
  price: 119.00,
  quantity: 1,
  currency: 'EUR'
});

3. Checkout started — pass the cart total and item count so you can compare started vs. completed value:

window.servoki.track('begin_checkout', {
  value: 238.00,
  items: 2,
  currency: 'EUR'
});

4. Payment details added — an optional late-funnel step that catches drop-off at the payment form:

window.servoki.track('add_payment_info', {
  value: 238.00,
  method: 'card',
  currency: 'EUR'
});

5. Purchase — the same confirmation event from above, now the final funnel step. The value is summed as revenue once you set value as the goal or funnel's revenue property (the built-in Ecommerce template does this for you):

window.servoki.track('purchase', {
  order_id: 'order_8841',
  value: 238.00,
  items: 2,
  currency: 'EUR'
});

Cart abandonment, for free. Because each step is its own event, the gap between add_to_cart and purchase in your funnel is your abandonment rate — no extra setup. Apply the Ecommerce template (or build a funnel view_itemadd_to_cartbegin_checkoutpurchase) in Goals & funnels to chart it.

Recommended: confirm purchases server-side

The reliable way to count revenue is from your backend, after payment is actually captured. Send a server event with an event_id so it deduplicates against the browser event if both fire:

curl -X POST https://servoki.com/api/events/server \
  -H "authorization: Bearer $SERVOKI_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "site": "{{site}}",
    "event_type": "purchase",
    "value": 49.90,
    "currency": "EUR",
    "event_id": "order_8841",
    "vid": "anon-abc123",
    "props": { "plan": "pro" }
  }'
  • value — a number, summed as revenue. Goals report revenue split by currency — different currencies are kept separate, never converted into one another.
  • currency — a 3-letter ISO code (e.g. EUR). Stored with the event, used to group revenue by currency, and forwarded to the Meta Conversions API.
  • event_id — your order id. Makes retries safe and deduplicates against the browser purchase for the same order.
  • vid — the same id you set in the browser with setVisitor(), so the server conversion stitches to the visit that drove it.

Stitching browser → server

Set a visitor id you control in the browser early in the journey:

window.servoki.setVisitor('anon-abc123');

Then pass that same id as vid on the server event. Now the purchase is attributed to the original source/campaign, even though it was confirmed on your backend.

Best of both: fire the browser purchase for instant feedback and the server event for truth. Matching event_ids mean it counts once.