Capture product view events

This is for:

Developer
Important

The Event Protocol and Relay library are currently in early access. 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) using the Relay library.

When to send a product view event

Any time a {product-detail-page} loads, a detail event must be sent, together with the product information payload. Depending on your site’s design, detail events can be triggered from different pages.

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

Capture a product view event using Relay

When the user views the product details, you must run the following:

const relay = createRelay({...}); 1
relay.emit('ecProductView', {  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 ecProductView 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.