Measure a Purchase

The following image is taken from a checkout confirmation page view of the fictitious online store, TheGym.

The user is about to complete a purchase and you want to measure this type of interaction. The data has only been set by the previous commands. It must be sent with either a pageview or with a generic event.

TheGym Checkout Confirmation Page View

Tracking Commerce Events Prerequisites

Before each event, ensure that you’ve:

How to Measure a Purchase

In the previous add to cart example, the user completes their purchase of a pair of ski boots.

First use the ec:addProduct command to include the relevant product data in the event you’re about to send:

coveoua('ec:addProduct', {
   'id': '037212201_DKBL',
   'name': 'backland 120',
   'brand': 'Atomic',
   'category': 'sport/ski_mountaineering/boots',
   'price': 447.20,
   'variant': '037212201_DKBL_22',
   'quantity': 1

When you structure your items with product grouping, ensure you add the group field to the product dataset. This will send all related items in the analytics payload.

You then use the ec:setAction command to specify that the action done on this data is a product purchase:

coveoua('ec:setAction', 'purchase', {
    'id': 'transaction-1234',
    'affiliation': 'TheGym',
    'revenue': '467.20',
    'tax': '42.47',
    'shipping': '20.00'

Finally, you use the send command to send the event to Coveo UA:

If Then

The purchase action and product information is added before the pageview event is sent

There’s no need to send the pageview event. The pageview event you previously configured on the page will contain the action and product information.

The user interaction didn’t open a new page

Manually send the purchase action with a generic event.

For transaction reference information, see Product Data Fields Reference.

What's Next for Me?