Skip to main content

shopify:product:view

Fires when a product becomes visible to a buyer, whether that's a product page, a card in a collection grid, or a recommendation. The context field tells you which, with page, collection, recommendation, search, or dialog.

You can use this to record what a buyer saw. Because it covers cards as well as full pages, one listener captures every product a buyer saw, including cards they never clicked.

A view-event custom element dispatches it, so a storefront wires it up in Liquid rather than in JavaScript. Add view-event-trigger="intersect" to fire when the card scrolls into view rather than when it's added to the page. See dispatching view events.

selectedVariant is null when no variant is selected, such as a product card in a collection grid.

Anchor to context
context
'page' | 'search' | 'collection' | 'dialog' | 'recommendation'
required

Where the buyer saw the product. Use this to tell a product page view apart from a card in a grid.

Anchor to selectedOptions
selectedOptions
[]
required

The options selected when the product came into view.

Anchor to product
product
required

The product the buyer saw.

Anchor to detail
detail
Record<string, unknown>

Optional custom data for the storefront's internal use. Listeners can read it.


Was this page helpful?