E-commerce Analytics
This guide covers how to set up TraceLog for an e-commerce site -- tracking product views, cart activity, checkout, and purchases.
Key Events to Track
| Event | When to Fire |
|---|---|
product_viewed | User views a product detail page |
product_added_to_cart | User adds an item to cart |
checkout_started | User begins the checkout process |
purchase_completed | User completes a purchase |
Code Examples
Product Browsing
tracelog.event('product_viewed', {
productId: 'SKU-001',
category: 'shoes',
price: 89.99,
currency: 'USD'
});
Cart Activity
tracelog.event('product_added_to_cart', {
productId: 'SKU-001',
quantity: 1,
price: 89.99
});
Checkout and Purchase
tracelog.event('checkout_started', {
itemCount: 3,
cartTotal: 249.97,
currency: 'USD'
});
tracelog.event('purchase_completed', {
orderId: 'ORD-789',
total: 249.97,
currency: 'USD',
itemCount: 3
});
Revenue Tracking
Turn your purchase events into revenue in the revenue setup wizard: pick your platform, follow the recommended install path, and TraceLog verifies it live. For custom stores that send their own events, the wizard uses event-based revenue — you map the value field in your event payload (e.g., total) and revenue is read from every order. See Revenue Tracking for the full flow, modes, and live verification.
Integrations
TraceLog integrates with popular e-commerce platforms:
- Shopify -- server-side webhook + checkout funnel for Shopify stores
- WooCommerce -- no-code plugin (or a developer PHP hook) for WooCommerce stores
- Stripe -- webhook-based purchase and subscription tracking
Recommended Funnel
Create a purchase funnel to visualize your checkout flow:
- Product view (Page View:
/products/*) - Add to cart (Custom Event:
product_added_to_cart) - Checkout (Custom Event:
checkout_started) - Purchase (Custom Event:
purchase_completed)
This shows you exactly where shoppers drop off and which step needs the most attention.
Dashboard Features to Use
- Goals -- set
purchase_completedas your primary conversion to track conversion rate across all dashboards - Campaign performance -- see which traffic sources and ad campaigns drive the most revenue
- Visitor segments -- compare purchasing behavior between new and returning visitors
Example Ask Questions
- "What's my conversion rate by traffic source?"
- "Which products have the highest cart abandonment?"
- "How does weekend revenue compare to weekdays?"
- "What's my average order value this month?"