Skip to main content

Overview

Tracking events at each stage of the user journey—from seeing products to clicking them—provides the data needed for analytics and recommendation improvements.

Event Flow

Each event builds on the previous, creating a complete picture of user behavior.

Tracking Search Results

Basic Implementation

Full Parameters

Tracking Recommendations

Tracking Clicks

Track when a user clicks on a product:
The position parameter is 0-indexed and represents where the product appeared in the results. This is crucial for understanding if users click items at position 1 vs position 20.

Tracking Views (Viewability)

Track when a product becomes visible to the user. Standard viewability requires:
  • At least 50% of the product visible
  • Visible for at least 1 second

Using Intersection Observer

Using Auto Track Plugin

For simpler implementation, use the AutoTrackPlugin:
See Auto Track Plugin for details.

Tracking Add to Cart

Track when a user adds a product to their cart:

Low-Level Tracking

For custom scenarios, use trackItemsServed directly:

Parameters

string
required
Where products are displayed. Common values: search_results, product_page, home_page, category_page, cart_page.
string
required
How products were generated. Values: text-search, image-search, similar-items, visitor-recs, user-recs, plp, curated.
string[]
required
Array of product IDs being served.
string
The search query, if applicable.
number
Total available results before pagination.
object
Custom key-value pairs for additional context.

Complete Page Implementation

Best Practices

Do:
  • Track clicks immediately on click, not on navigation complete
  • Track views with a 1-second delay to filter accidental scrolls
  • Track add-to-cart before the actual cart operation
  • Use consistent surface and source values across your app
Don’t:
  • Track views on render (before user could actually see them)
  • Track clicks multiple times for the same interaction
  • Forget to track interactions from keyboard navigation
  • Block user interactions while waiting for tracking to complete

Next Steps

Conversion Tracking

Track purchases and attribution

Auto Track Plugin

Automatic event tracking