Ecommerce
Statalog gives you a complete ecommerce analytics view — revenue, orders, average order value, conversion rate, and top products — using the same lightweight tracker you already have on your site. There's no separate "ecommerce SDK" to install, no extra script to load, and no setting to enable. Send one custom event from your checkout success page and the dashboard lights up automatically.
How it works
When a customer completes a purchase, your site fires a single event:
Statalog.track('purchase', {
value: 99.99,
currency: 'USD',
order_id: 'ORD-12345',
product_id: 'sku-blue-shoe-42',
product_name: 'Blue Running Shoes',
quantity: 1
});
That's it. The event lands in the same custom_events table that powers the Custom Events report. A dedicated Ecommerce section then appears on your dashboard, between the main traffic chart and the existing detail cards. The section only renders when the site has at least one purchase event in the selected date range — non-ecommerce sites never see it.
What you'll see on the dashboard
Four headline metrics
| Metric | What it measures |
|---|---|
| Revenue | Sum of every value property across all purchase events in the range |
| Orders | Count of purchase events |
| Avg order value | Revenue ÷ Orders |
| Conversion rate | Orders ÷ Total sessions × 100 |
Each card shows a period-over-period trend (up/down %) so you can immediately see whether revenue is growing or slipping compared to the previous identical date range.
Revenue over time
A line chart of daily revenue across the selected range, in your site's timezone. Use this to spot weekly seasonality, campaign impact, or sudden drops.
Top products
A horizontal-bar widget showing your top 10 products by total revenue. Each row displays the product name (or product ID if no name was sent), revenue contribution, and number of orders. Statalog reads product_name first, then falls back to product_id.
Recommended events
Statalog's data model is intentionally flexible — any event_name you choose works. We recommend the following names because they match Google Analytics 4 conventions, so your team's mental model is consistent across tools:
| Event | When to fire it | Important properties |
|---|---|---|
view_item |
Product page loaded | product_id, product_name, price, category |
add_to_cart |
Item added to cart | product_id, value (item price × qty) |
begin_checkout |
Checkout started | value (cart total), items (count) |
purchase |
Order completed (powers the Ecommerce section) | value, currency, order_id, product_name or product_id |
refund |
Order refunded | order_id, value (negative) |
You can fire as few or as many of these as you like. Only purchase is required to light up the Ecommerce section; the others enrich the Custom Events report and let you build Funnels like view_item → add_to_cart → begin_checkout → purchase.
Property reference for purchase
| Property | Type | Required | Notes |
|---|---|---|---|
value |
number | yes | Order total. Used for revenue, AOV, top-products. Send pre-tax, after-discount — whatever number you actually charged. |
currency |
string | recommended | ISO 4217 (USD, EUR, GBP). Statalog displays revenue in $ regardless today; this property is stored for future multi-currency support. |
order_id |
string | recommended | Your internal order reference. Useful for de-duplicating, exporting, and matching with your billing system later. |
product_id |
string | recommended | SKU or unique product identifier. |
product_name |
string | recommended | Human-readable name shown in the Top products widget. Falls back to product_id when absent. |
quantity |
number | optional | Number of items in the order. |
category |
string | optional | Product category — handy for grouping in the Custom Events report. |
For multi-product orders you have two options:
- Send one
purchaseevent withvalue= order total. The Ecommerce section credits the entire revenue to a single line. Top products will show the product you set on the event. - Send one
purchaseevent per line item (each with that item's value). The Ecommerce section sums revenue correctly across all rows, and Top products attributes revenue to each individual product. This is more accurate for stores selling multiple SKUs per order.
Most stores find option 2 more useful for the Top products view.
Platform integrations
Shopify
In Shopify Admin → Settings → Checkout → Order processing → Additional scripts, paste the regular Statalog snippet plus this block:
{% if first_time_accessed %}
<script>
Statalog.track('purchase', {
value: {{ checkout.total_price | money_without_currency | remove: ',' }},
currency: '{{ shop.currency }}',
order_id: '{{ checkout.order_id }}',
items: {{ checkout.line_items.size }}
});
</script>
{% endif %}
The first_time_accessed guard prevents the event from re-firing if a customer refreshes the success page or returns to it from their email confirmation.
WooCommerce
Add to your theme's functions.php:
add_action('woocommerce_thankyou', function ($order_id) {
$order = wc_get_order($order_id);
if (!$order) return;
?>
<script>
Statalog.track('purchase', {
value: <?= $order->get_total(); ?>,
currency: '<?= $order->get_currency(); ?>',
order_id: '<?= $order->get_order_number(); ?>',
items: <?= $order->get_item_count(); ?>
});
</script>
<?php
});
Custom checkout (React, Vue, Next.js, server-rendered, etc.)
After successful payment confirmation:
window.Statalog?.track('purchase', {
value: order.total,
currency: order.currency,
order_id: order.id,
product_name: order.items[0].name
});
The optional chaining (?.) prevents errors if the tracker is blocked by an ad blocker or hasn't loaded yet — you'll silently miss that event but the page won't break.
Server-side tracking
If you'd rather track purchases from your backend (more reliable than browser events, since ad blockers and crashed tabs can drop client-side calls), use the REST API with event_name: 'purchase'. See the REST API docs for details.
What ties it together
Statalog deliberately doesn't ship a separate "ecommerce module". Everything you see on the dashboard is computed live from your existing custom events:
- Revenue, AOV, top products — read directly from
purchaseevent properties via ClickHouseJSONExtractfunctions - Conversion rate — joins
purchaseevent count against your existing session count - Trend badges — re-runs the same query on the previous identical date range
- Funnels — work because each step (page or event) is queried the same way as everywhere else
This means:
- ✅ No migrations to run when you start tracking sales
- ✅ Existing UTM, channel, and referrer reports immediately show "which campaign drove the most revenue" via the Goals report
- ✅ You can change what you track at any time — just emit different properties
- ✅ Privacy properties stay intact — visitor IDs are still hashed and don't carry order details across sessions
Privacy considerations
Avoid sending personally identifiable information in event properties:
- ❌ Don't send
email,customer_name,phone, full addresses - ❌ Don't send raw credit-card data (PCI compliance)
- ✅ Do send
order_id,product_id,value,category
If your team needs revenue tied to specific customers (e.g. for LTV calculations), join order_id with your billing database privately, off-Statalog. Statalog stores order_id as a string but doesn't surface it in the dashboard — you can pull it via the REST API when needed.
Related
- Custom events — the underlying tracking primitive
- Goals & conversions — set up "Purchase" as a goal for per-channel revenue attribution
- Funnels — multi-step paths like cart → checkout → purchase with drop-off analysis
- REST API — server-side event submission