Skip to main content

Overview

E-commerce tracking helps you understand how customers shop, where they drop off, and what drives purchases. Grain provides template events specifically designed for online stores.

Key Metrics to Track

Conversion Funnel:
  • Product views → Add to cart → Checkout → Purchase
Engagement:
  • Search behavior and results
  • Product browsing patterns
  • Cart interactions
Revenue:
  • Order values and items
  • Payment methods
  • Discount code usage

Product View Tracking

Track when users view products:
Why track this? Understand which products attract attention and compare views to purchases.

Add to Cart

Track cart additions to measure interest:

Remove from Cart

Track when items are removed:
Insight: High remove rates might indicate pricing issues, unexpected costs, or product concerns.

Checkout Tracking

Track the entire checkout process:

Purchase Completion

Track successful purchases:
Flush immediately: Ensures the event sends before the user navigates away.

Complete Shopping Flow

Here’s a full example tracking the customer journey:

Abandoned Cart Recovery

Track cart abandonment to understand drop-off:

Discount Code Tracking

Track promotion usage:

Analyzing the Funnel

With these events, you can analyze your funnel:
  • View to Cart: product_viewedadd_to_cart
  • Cart to Checkout: add_to_cartcheckout
  • Checkout to Purchase: checkoutpurchase
View the data in your Grain Dashboard to identify where users drop off.

Best Practices

1. Track Early: Capture events as soon as actions happen. 2. Include Context: Always add product IDs, prices, and quantities. 3. Flush Critical Events: Use flush: true for purchases and checkouts. 4. Consistent Currency: Always specify currency codes (USD, EUR, etc.). 5. Full Item Details: Include complete item information for better analysis.

Next Steps

Template Events

See all e-commerce event methods

User Properties

Track customer attributes

A/B Testing

Test different shopping experiences