Sub topic 6
Product discovery: `view_item_list`, `select_item`, and `view_item`
Assume you understand GA4 events, JavaScript objects and arrays, and the basic structure of a product catalog. This chapter focuses on the discovery stage of an e-commerce funnel: showing products, recording selections, and recording product-detail views.
The three discovery events
GA4 uses three recommended events:
| Event | When to send it | Main purpose |
|---|---|---|
| `view_item_list` | A product list is visible | Records which products were displayed |
| `select_item` | A shopper selects a product from a list | Connects the selection to the displayed list |
| `view_item` | A product-detail page or view is shown | Records interest in one product |
Each event carries an items array. The array contains one object for each product involved in the event.
`view_item_list`
Send view_item_list when the list is rendered or becomes visible according to your measurement design. Include a shared item_list_id or item_list_name, such as search_results or featured_products.
Each item should have a stable item_id, a readable item_name, a price, and an index. The index identifies the product's position in the list. Use a consistent indexing convention throughout the site.
`select_item`
Send select_item when the shopper clicks or otherwise selects a product from a list. Include the same list identifier and the selected item. The item's index should match its position when it was displayed.
`view_item`
Send view_item on the product-detail page or equivalent product view. Include the product's current price and quantity, normally 1. Send currency and value when reporting the product's monetary value.
gtag('event', 'view_item_list', {
item_list_id: 'featured_products',
item_list_name: 'Featured products',
items: [
{
item_id: 'SKU_1001',
item_name: 'Trail Running Shoe',
item_brand: 'Acme',
item_category: 'Shoes',
price: 24.99,
index: 0
},
{
item_id: 'SKU_1002',
item_name: 'Hiking Backpack',
item_brand: 'Acme',
item_category: 'Bags',
price: 59.99,
index: 1
}
]
});
gtag('event', 'select_item', {
item_list_id: 'featured_products',
item_list_name: 'Featured products',
items: [{
item_id: 'SKU_1001',
item_name: 'Trail Running Shoe',
price: 24.99,
index: 0
}]
});
gtag('event', 'view_item', {
currency: 'USD',
value: 24.99,
items: [{
item_id: 'SKU_1001',
item_name: 'Trail Running Shoe',
price: 24.99,
quantity: 1
}]
});Common errors
- Sending
view_item_listbefore the list has real products. - Omitting
itemsor sending an empty array. - Reusing the same
indexfor every product. - Recording
select_itemwithout the list identifier. - Sending a product's list price in one event and its current selling price in another.
- Firing
view_itemrepeatedly on every component update instead of once per meaningful product view.
Exercise
A shopper selects the third product in a list whose ID is search_results. Which index should the select_item item use if your site indexes the first product as zero?
Show answer
Use index: 2, because zero-based indexing assigns positions 0, 1, and 2 to the first, second, and third products.