Capture click 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 click events and send the information to Coveo Usage Analytics (Coveo UA).

When to capture a click event

A click event should be captured when a visitor clicks a product rendered using Coveo. For example, results displayed on a search results page, product listing page (PLP), a recommendations carousel, or a search-as-you-type search box. Tracking click events is a requirement for Coveo Machine Learning (Coveo ML) and usage analytics reporting.

Click events and attribution

Coveo attributes transactions to product discovery solutions by tracking touchpoints along the user journey. In a Coveo-powered commerce implementation, click events are the main touchpoints used for attribution.

You need to send click events to track attribution on the Coveo for Commerce Advanced Reports.

For more information, see Attribution at Coveo.

Example

A user performs a query on a Coveo-powered commerce site. They click a product to open its product detail page (PDP), but they don’t make a purchase and navigate away from the site. Coveo tracks this touchpoint as part of the user’s journey.

Later, they revisit the site and see the same product in a recommendation slot. They click the product to open its PDP, creating another touchpoint tracked by Coveo. This time, the user adds the product to their cart and completes the purchase. This product is attributed to the recommendation solution.

How to capture a click event

Capturing a click event depends on your implementation approach.

Capture a click event using Headless

If you’re using the Headless library, you can capture a click event by using the InteractiveProduct sub-controller for the solution you’re building.

For more details, see Displaying Products.

Capture a click event using Relay

If you’re using Relay library directly, when a user clicks on a product, you can run the following code to capture the click event and send the information to Coveo UA.

const relay = createRelay({...}); 1
relay.emit('ec.productClick', { 2
    currency: 'USD', 3
    position: 1,
    responseId: '35009a79-1a05-49d7-b876-2b884d0f825b',
    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. For example, the value is ec.productClick since it’s tracking a click 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 click 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.