Commerce UA API reference
Commerce UA API reference
This is for:
DeveloperCoveo UA command list
The Coveo UA library provides a set of commands to send commerce events to Coveo and track user interactions.
Commands | Description | Associated parameters |
---|---|---|
|
Initializes the Coveo UA JavaScript |
|
|
Sets the website context or user ID |
|
|
Returns the current version of the tracking library |
|
|
Includes the relevant product data in the event you’re about to send |
|
|
Specifies the action done on this data |
|
|
Sends an event with a given name and payload to the analytics endpoint |
|
Global fields reference
User fields reference
Users fields are related to the current user.
userId
(string)
Example: myuser@mycompany.com
Before using the |
currencyCode
(string)
The currency code is a three-letter code that identifies the user’s currency.
The code follows the ISO 4217
standard.
Example: CAD
anonymizeIp
(boolean)
Use this field to anonymize the IP address by removing the last subnet of the current user’s IP address.
Coveo will never store unencrypted IPs, even when this setting is set to false
.
loyaltyCardId
(string)
A unique identifier provided to a returning user.
loyaltyTier
(string)
A level of membership where users receive perks and benefits depending on their rank.
Example: Platinum
thirdPartyPersona
(string)
This represents additional market segmentation based on user characteristics (demographics, interests, needs, or location) which aren’t created by Coveo Machine Learning (Coveo ML). When you already have a set of segments for your users, enter the information in this field.
trackingId
(string)
Note
Available on version 2.28.15 of the Coveo UA library and greater. |
The value to identify which web property an event is related to. This is a human-readable name you can use when sending analytics events.
{
...
"trackingId": "online_store",
...
}
See Tracking ID for more information.
companyName
(string)
The name of a specific company for business-to-business sales.
favoriteStore
(string)
The primary store selected by a returning user.
storeName
(string)
The name of the current store selected by the user.
userIndustry
(string)
For business-to-business (B2B) environments that need to indicate which industry’s vertical structure the user belongs to (for example, healthcare,technology, insurance).
userRole
(string)
For business-to-business (B2B) environments that need to indicate the role or title of the current user (for example, director, manager, specialist).
userDepartment
(string)
For business-to-business (B2B) environments that need to indicate the department of the current user (for example, IT, Design, Procurement, Sales).
businessUnit
(string) - deprecated
This field has been deprecated. You no longer need to send this data when logging analytics events. |
This field defines the current catalog entity in use. For a solution with multiple catalog entities, Coveo uses the one passed in this field to separate reporting and machine learning between catalog entities.
Page fields reference
The page view event has been deprecated and is no longer necessary to send. Unless you are creating custom reports using this event, we recommend that you stop sending it, as doing so will simplify your implementation. |
Page fields are sent using the set
command, or alongside a pageview
event as shown in the following command:
coveoua('send', 'pageview', {
page: '/mypage'
})
page
(string)
The path portion of the page URL that allows users to track pages for single page apps (SPA) and mobile apps.
To send the page
, add the following line before sending the pageview
event, for example:
coveoua('set', 'page', window.location.pathname)
title
(string)
The title of the page. The default value is retrieved from document.title
.
Example: My Super Site
location
(string)
The full URL of the page. The default value is retrieved from document.location
.
Example: https://www.mysupersite.com/home
Global custom fields reference
The custom
field allows users to add additional custom values as an object.
Everything in this field will be unfolded to the parent object and then sent to coveoua
.
To set custom fields for the whole page, use the set
command, passing the custom
string as a second argument, and an object containing the desired key-value pairs as a third argument.
On custom user data
coveoua('set', 'custom', {
visitorAge: 18,
rewardsMember: true
});
// sets the `custom` field for each top-level object
When you use the send
command
coveoua('send', 'custom');
The following data is sent to coveoua
:
visitorAge: 18,
rewardsMember: true
Product data fields reference
Product fields reference
Product fields are set with the ec:addProduct
command.
id
(string)
The unique identifier of the product. The value must match exactly, including case, the value of the product identifier field configured in the catalog entity.
Note
The product identifier field must be mapped to the |
Example: 001-red
name
(string)
Example: Very nice shoe
brand
(string)
Example: Coveo
category
(string)
Represents a grouping of products having particular shared characteristics.
Field format | Examples |
---|---|
Single |
|
Hierarchical |
|
Multi-value |
|
When logging events, the Coveo Platform expects the category
values to be sent in a different format than when configuring category
values for your products.
The format expected when uploading category
values to your index is |
for delimiting hierarchies and ;
for delimiting multiple values.
Whereas the format expected when logging events is /
for delimiting hierarchies and |
for delimiting multiple values.
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 Canoes & Kayaks ; Canoes & Kayaks|Kayaks ; Canoes & Kayaks|Kayaks|Tandem Kayaks
, you only need to send Canoes & Kayaks/Kayaks/Tandem Kayaks
in the event.
Ensure that you aren’t sending events that include breadcrumbs with temporary categories or events, such as |
group
(string)
In the context of product grouping, this is a unique identifier which is specific to an item that has multiple siblings attached to it. This is useful if you only want one item per group to be recommended by the machine learning algorithms.
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, |
variant
(string)
A string that defines the unique non-displayable version of the product. Often called a stock keeping unit (SKU).
Example: 001-red-8_wide
Note
If the For example, when a user lands on a product detail page where a |
price
(Monetary values)
The price of the product.
The value cannot be blank, therefore use 0
when a product has no price.
Price values are only meaningful if accompanied by a currencyCode
.
Example: 12.34
quantity
(numeric)
Quantity of the product bought.
Example: 12
coupon
(string)
The name of the coupon used on this specific product.
Example: PROMO-1234
position
(numeric) - deprecated
This field has been deprecated. You no longer need to send this data when logging analytics events. |
The item’s position.
For example, the first item displayed in a list should have position: 1
.
Example: 2
Note
For products, only a position greater than or equal to |
Transaction fields reference
Transaction fields are set with coveoua('ec:setAction', <ACTION>)
id
(string)
A unique transaction identifier used to track a purchase.
Example: transaction-1234
affiliation
(string)
The store where a transaction took place. Sent when you want to link a purchase
to a specific store.
Example: Shoe Store
revenue
(Monetary values)
The total value of the transaction, including taxes and shipping.
Example: 123.21
coupon
(string)
The name of the coupon used on the whole transaction.
Example: PROMO-FREE-SHIPPING-2020
Quote fields reference
Field references related to providing a quote to the user.
id
(numeric)
An identifier used to track a specific transaction.
affiliation
(string)
The store where a quote took place. Sent when you want to link a quote
to a specific store.
Example: Shoe Store
Review fields reference
Review fields provide customers the opportunity to rate and comment on products they have purchased.
id
(numeric)
An identifier used to track a specific transaction.
rating
(numeric)
A rating described on a numeric scale from 0 to 10.
Note
When using a different rating method, for example a review of 0 to 5 stars, ensure you convert the score to a 0 to 10 scale. |
comment
(string)
A written summary of a user’s experience with a product or service.
Product data custom fields reference
The custom
field allows users to add additional custom values as an object.
Everything in this field will be unfolded to the parent object and then sent to coveoua
.
To set custom fields in a product impression, use the ec:addProduct
command, and add a custom
object containing the desired key-value pairs in your main product impression object.
On custom product data, when you use the ec:addProduct
command
coveoua('ec:addProduct', {
'id': '001-red',
'name': 'A very nice pair of shoes',
'brand': 'Coveo',
'category': 'Running shoes',
'price': 90.22,
'variant': '001-red-8_wide',
'custom' : {
'onSale' : false
}
});
When you use the send
command
coveoua('send', 'event');
It will send the following data
id: '001-red',
name: 'A very nice pair of shoes',
brand: 'Coveo',
category: 'Running shoes',
price: 90.22,
variant: '001-red-8_wide',
onSale : false
Product action types
When capturing a commerce event that requires a product data payload, you must use the ec:setAction
command to specify a product action type.
Product action types are the actions that users can perform on products.
They’re used to specify event types to Coveo UA and to track the user’s behavior on the site.
The following table lists the required product action types supported by the Coveo UA library for a complete implementation. These actions feed Coveo ML models and out-of-the-box advanced commerce reports.
Action | Description |
---|---|
|
The user clicked a product. |
|
The user added or removed a product from their cart. |
|
The user accessed a product detail page. |
|
The user completed the purchase of one or more products. |
Monetary values
Currency is a specification of a monetary amount. The following table lists the acceptable currency data types.
Currency data type | Examples |
---|---|
A positive or negative integer. |
|
A positive or negative decimal value with up to 6 decimal places using |
|
A string, which may contain a non-numeric prefix in front of an integer or decimal value.
In this case, Coveo interprets the number by stripping away the prefix up to the first numeric, |
Acceptable strings include |
Note
Coveo doesn’t support numbers using different decimal separators other than |
Search hub
The name or identifier of the search interface from which a given UA event originates.
Depending on the type of interface from which the event originates, the value of the search hub must contain:
Type of interface | Contains the string |
---|---|
A search page |
|
A product listing page |
|
Note
For recommendation components, the attribution mechanism is automatically managed by tracking a unique ID throughout the actions leading to a product being added to a cart or purchased.
Therefore, there’s no specific naming convention to use when choosing a search hub value for your recommendation component, but note that it’s a good practice to add However, the identifier value of the recommendation component is used for reporting purposes.
Specifically, the Coveo UA service utilizes the To ensure clarity and easy recognition, we strongly recommend assigning a meaningful and recognizable value as the identifier for your recommendation component. You can achieve this by setting the |
coveoua('send', 'event', {
"searchHub": "<SEARCH_HUB>"
});
Where <SEARCH_HUB>
is the name of your search hub (for example, "storefront_search" for a search page or "MyBrand_listing" for a product listing page).
If searchHub
isn’t specified and the request is authenticated with a search token, the service tries to extract the searchHub
value from the access token that authenticated the request to log a search event (see Set the Search Hub).
Coveo ML models use the |