Capture product view events

This is for:

Developer
Important

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.

Examples

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.

Barca Product Detail View

How to capture a product view event event

Capturing a product view event depends on your implementation approach.

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({...}); 1
relay.emit('ec.productView', {  2
    currency: 'USD', 3
    product: {
        productId: 'SP03929_00014',
        name: 'Blue Bottle',
        price: 16,
    },
});
1 Initialize a Relay instance.
2 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.
3 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 meta object mentioned in the Event Protocol Reference documentation, as it’s automatically added by the library.

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.