Capture a product detail view event
Capture a product detail view event
This is for:
DeveloperThis article explains how to capture product detail view events and send the information to Coveo using the Coveo UA library.
When to send a product detail view event
Any time a product detail page (PDP) loads, a detail event must be sent to Coveo, 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.
Capture a product detail view event using Coveo UA library commands
When the user views the product details, you must run the following JavaScript code which contains Coveo UA library commands.
coveoua('ec:addProduct', {
'id': 'SP00763_00002',
'name': 'Modal Blue T-shirt',
'category': 'clothing/t-shirts',
'price': 42.00
});
coveoua('ec:setAction', 'detail');
coveoua('send', 'event');
Add product data payload | |
The currencyCode for the item’s price is set as a global field when initializing the Coveo UA library |
|
Set the action type | |
Send the event |
Add product data payload
The ec:addProduct
command includes the relevant product data in the event you’re about to send.
In this case the product dataset contains the product id
, name
, category
, and price
.
For more information, refer to the Coveo UA command list.
Product detail view dataset requirements
The following table lists the fields sent along with the event and the solutions that use these fields. Search, Listings, and Recs columns refer to whether the ML that powers those solutions needs those data points. The Reporting column is for general reporting purposes that encompasses all solutions. For more information on these fields, including other recommended and optional fields that can be sent, refer to the Product fields reference.
Field | Priority | Search | Listings | Recs | Reporting |
---|---|---|---|---|---|
Required |
|||||
Required |
|||||
Required |
|||||
Required |
|||||
Recommended |
|||||
Recommended |
|||||
Recommended |
-
Only needed when you need to setup ML to recommend at the group level.
Note
When you structure your items with product grouping, ensure that you add the Using the recommended approach for product data, you would find, for example, |
Set the action type
The ec:setAction
command detail
is used to send the product data payload.
Send the event
Finally, the send
command sends an event
with a given payload to the Coveo analytics endpoint.
Product detail view event validation
When the product detail view event is logged, use the developer tools for client-side request verification to inspect the event content to ensure everything done using the UI is captured as a set of consistent and coherent events. This must occur after the implementation is applied.
Inspect the product detail view event through the network browser and ensure it satisfies the following:
1 The client ID (cid
) is consistent with other events sent on the page.
2 The currency matches what’s being displayed to the visitor.
3 Confirm the event is a product detail
view (pa
).
4 Category values should use /
to represent hierarchies and use |
to represent multiple values.
Note
When logging events, the Coveo Platform expects the The format expected when uploading When logging events, the Coveo Platform only requires the last level of the hierarchy to be sent. For example, if you have a category defined in the index as |
5 The product ID (pr1id
) matches what’s set in the catalog.
Similarly, if group
and variant
are being sent, they must also match.
Event field data mapping
The following table shows how the client-side fields are mapped to parameters in the analytics request sent to Coveo UA. You need to ensure this information is properly passed in the payload.
Field name | Description | Parameter |
---|---|---|
Identifier for the base product |
||
The product category |
||
The price shown to the user (including discounts) |
||
The product brand |
||
The product name |
||
The product group ID |
||
The exact SKU of the variant selected |
For a complete list of parameters that can be sent in the event, see Log Collect events.