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
To aggregate revenue data in your dashboard:
- Go to Project Settings > Revenue
- Select the Transactional revenue model (one-time purchases)
- Map the revenue field from your event metadata (e.g.,
total)
Integrations
TraceLog integrates with popular e-commerce platforms:
- Shopify -- automatic event tracking for Shopify 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 Copilot 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?"