Capture product view events
Capture product view events
This is for:
Developer
The Event Protocol and Coveo Relay are currently in open beta. If you’re interested in using the Event Protocol and Relay library, reach out to your Customer Success Manager (CSM). |
This article explains how to capture product view events and send the information to Coveo Usage Analytics (Coveo UA).
When to send a product view event
Any time a product detail page loads, a product view event must be sent, together with the product information payload. Depending on your site’s design, detail events can be triggered from different pages.
All the following interactions require sending a product view event:
-
A user searches for products, clicks one, and lands on the PDP.
-
A user navigates to a PDP directly using a link.
-
A user already on a PDP selects an option for a same product but with a different color.
The following image is taken from a product detail page view of the online sporting goods store Barca Sports, which contains product specific information.
How to capture a product view event event
Capturing a product view event depends on your implementation approach.
-
If you’re using Headless, capture the event using the Headless controllers.
-
If you’re not using Headless, use the Relay library directly to capture the event.
Capture a product view event using Headless
If you’re using the Headless library, you can capture a product view event by using the ProductView
controller.
For more details, see Displaying Products.
Capture a product view event using Relay
If you’re using Relay library directly, when the user views the product details, you must run the following:
const relay = createRelay({...});
relay.emit('ec.productView', {
currency: 'USD',
product: {
productId: 'SP03929_00014',
name: 'Blue Bottle',
price: 16,
},
});
Initialize a Relay instance. | |
Use the emit function to send an event with Relay, specifying the event name.
In this example, the value is ec.productView since it’s sending a product view event. |
|
Include the necessary event data, as outlined in the reference documentation. |
For a detailed description of the functions offered by the library, see the Relay documentation.
Note
When sending events with Relay, you don’t need to include the |
Validating the product view event
It’s important to verify that your event is valid and contains the correct payload. Relay seamlessly integrates with Coveo Explorer, which can be used for event validation.
For more details on using Coveo Explorer to validate events, see Validating events.