Skip to main content

Category Viewed (category_viewed)

Purpose: Track when a user lands on or refreshes a category listing page to view products in that category. When to Fire: After your page or API loads the category data and product SKUs typically on page load or when your view changes to a category view. Payload Schema:
FieldTypeDescription
category_idstring or numberUnique identifier of the category.
category_namestringHuman‑readable category name.
skuarray of stringsFlat array of SKUs for all products in this category.
search_sourcestringFor suggestion clicks, pass the autocomplete category key from the response (e.g., "category").
used_suggestionstringThe exact suggestion text the user clicked (e.g., “shirts”, “jeans”).
facetsarrayActive filters (e.g. size, brand)—each { field, value }. Use an empty array if none.
request_idstringUnique identifier for the search request (x-request-id from response headers).
page_depthstringCurrent page number (1, 2, 3, etc.).
Example:
// Assume these variables are populated from your category response and UI state:
const categoryId      = 'cat123';
const categoryName    = 'Running Shoes';
const selectedFacets  = [];       // e.g. [{ field: 'size', value: '10' }]
const requestId       = categoryResponse.headers.get('x-request-id');
const currentPage     = 1;        // Current page number (1, 2, 3, etc.)
const products        = [
  { sku: 'RS-001', name: 'Lightweight Runner' },
  { sku: 'RS-002', name: 'Marathon Pro' }
];

ExpAnalyticsService.trackCategoryViewed({
  category_id: categoryId,
  category_name: categoryName,
  sku: products.map(p => p.sku),
  used_suggestion: usedSuggestion,
  search_source: searchSource,
  facets: selectedFacets,
  request_id: requestId,
  page_depth: currentPage
});