Overview
Event tracking captures user interactions—impressions, clicks, views, adds-to-cart, and purchases. This data powers:- Analytics: Understand how users interact with search and recommendations
- Attribution: Link sales back to the search or recommendation that drove them
- Model Improvement: Feedback loops that improve recommendations over time
The ServeContext Pattern
When products are displayed, you create a ServeContext that tracks subsequent interactions:Quick Start
Event Types
Tracking Methods
trackSearch()
Convenience method for search results:trackRecommendations()
Convenience method for recommendation results:trackItemsServed()
Low-level method for custom scenarios:trackPurchase()
Track completed purchases:ServeContext Methods
After calling a track method, you get a context with these methods:function
Track when a user clicks on a product.
position is the 0-indexed position in the results.function
Track when a product becomes visible. Call when 50%+ of the product is visible for 1+ second.
function
Track when a user adds a product to their cart from this serve context.
Event Queue Management
Events are automatically batched and sent. You can control this behavior:Configuration
Control batching, persistence, and retries in SDK initialization:Page Unload Handling
Ensure events are sent before the user leaves:Complete Example
Next Steps
Tracking Events
Detailed tracking implementation
Conversion Tracking
Purchase and conversion attribution
Auto Track Plugin
Automatic event tracking