E-commerce events
A standard e-commerce taxonomy with revenue and AOV queries.
Standard e-commerce funnel:
viewed_product → added_to_cart → started_checkout → completed_checkout → refundedPlus product browse signals (viewed_collection, searched) and post-purchase (reviewed_product).
Suggested taxonomy
viewed_product
product detail page renders
product_id, price_cents, currency, category
added_to_cart
"Add to cart" button
product_id, quantity, price_cents, currency
removed_from_cart
item removed from cart
product_id, quantity
started_checkout
checkout page load
cart_value_cents, currency, item_count
applied_discount
discount code applied
code, discount_cents
completed_checkout
order placed
order_id, amount_cents, currency, item_count, payment_method
refunded
refund issued
order_id, amount_cents, currency, reason
Money in cents as integers. currency always alongside any amount.
Instrument the storefront
import { track } from "@millimetric/track";
export function ProductPage({ product }: { product: Product }) {
useEffect(() => {
track("viewed_product", {
product_id: product.id,
price_cents: product.priceCents,
currency: "usd",
category: product.category
});
}, [product.id]);
return (
<button onClick={() => addToCart(product, 1)}>Add to cart</button>
);
}
function addToCart(product: Product, qty: number) {
cart.add(product, qty);
track("added_to_cart", {
product_id: product.id,
quantity: qty,
price_cents: product.priceCents,
currency: "usd"
});
}Track the order from the server
For Stripe webhooks, do the same in your webhook handler and pass order_id so you can dedupe on retry.
Refunds
Querying
Revenue per day
Average order value (AOV) by channel
Funnel: view → cart → checkout → order
Cohort retention (do they come back?)
For the cohort that purchased in week W0, what fraction purchased again in week W1, W2, …?
Common pitfalls
amountinstead ofamount_cents. Floats are not your friend in revenue math. Always use integer cents and storecurrencyexplicitly.Tracking
completed_checkoutfrom the success page. Anyone refreshing it double-counts. Track from the server, on order creation, withevent_id = order.idso you can dedupe in queries.Mixing currencies. Don't sum
amount_centsacross rows with differentcurrencyvalues. Convert in the query, or split by currency.No
is_first_purchaseflag. It's trivial to compute, easier in queries, and answers half the marketing-attribution questions cleanly.
See also
Properties — full conventions.
Marketing attribution dashboards — credit channels for revenue.
Server-side events — why critical events should come from the server.
Last updated
Was this helpful?