Handle dynamic and customer-specific pricing
Handle dynamic and customer-specific pricing
Many ecommerce ecosystems, including B2B businesses and multi-location retailers such as grocery chains, support multiple prices per product. These prices may vary based on various factors, including buyer groups, contracts, regions, individual stores, or even promotional programs and rewards.
Pricing variations can be defined in structured price lists stored in the catalog data, or determined dynamically at runtime by external pricing systems. External pricing systems are typically used when prices must be calculated dynamically, based on custom logic, real-time data, or complex conditions.
Coveo provides best practices and flexible strategies to support both static and dynamic pricing models.
Why you should index pricing data
You should always make pricing data available in your Coveo organization, as it plays a crucial role in various Coveo features, including:
-
Sorting and filtering in Coveo-powered interfaces, allowing visitors to sort products by price or filter results based on price ranges.
-
Coveo Merchandising Hub (CMH) merchandising rules, which can use price attributes to define conditions and actions.
-
Search result templates, which can display product prices in search results.
-
Coveo Machine Learning (Coveo ML) models, such as the Session-Based Product Recommendations (SBPR) model and the Cart recommender strategy of the Product Recommendation (PR) model use price attributes to improve relevance and personalization.
In Coveo for Commerce, two commerce standard fields are used to store product prices:
-
ec_price
: This field is used to store the base price of a product. This field is essential for the proper functioning of some Coveo features, such as ML models. Therefore, it should always contain a single value. -
ec_promo_price
: This field is used to store the promotional price of a product, if applicable.
However, these fields don’t support storing multiple values, so it’s important to adopt a strategy to manage multiple prices per product, while still providing a value for the ec_price
field.
|
Note
Providing a value for the |
Indexing strategies for dynamic pricing
Consider the following strategies when implementing customer-specific or dynamic pricing in Coveo for Commerce:
-
Dictionary field on the product (recommended): This strategy allows you to store multiple prices in a dictionary field on the product, enabling Coveo to extract the correct price at query time based on user context. In this strategy, you must also index a fallback value in the
ec_price
field to ensure Coveo ML models can use it. -
Index a fallback price: If you can’t index all possible prices, or if the pricing logic is too complex to represent as dictionary keys, you can store a fallback value in the
ec_price
field. This allows you to provide a price value for Coveo ML models and other features, while still allowing for dynamic pricing at query time. -
No indexing: If you can’t index pricing data at all, you can omit it. However, you won’t be able to use pricing in Coveo ML models and merchandising rules. Your visitors won’t be able to sort or filter products by price.
The following table summarizes the pros and cons of each strategy:
Strategy | Pros | Cons |
---|---|---|
Dictionary field on the product (recommended) |
|
With a high number of price entries, updates may result in noticeable delays before the new prices are reflected. |
Index a fallback price |
|
|
No indexing |
|
|
Strategy 1: Dictionary field on the product (recommended)
If you can index all possible prices for a product, the recommended approach is to use a dictionary field on the Product
catalog object.
This approach requires you to:
-
Define a custom dictionary field to store pricing values.
-
Index the
ec_price
field with a fallback value.
Step 1: Define a custom field to store prices
The ec_price
standard field doesn’t support dictionary values.
Therefore, you must index price values as a distinct metadata and store them in a custom dictionary field.
|
When configuring a dictionary field, make sure to follow the best practices and keep in mind the limitations. |
-
In your catalog data, store all price values in a dictionary object (for example
price_list
) so that Coveo can extract the correct price at query time.ExampleIn the following catalog data sample,
price_list
is a dictionary object with key-value pairs. It defines different prices based on the user’s subscription level:{ [...] "ec_product_id": "12345", "ec_name": "Example Product", "price_list": { "Default": 4000.00,
"Vip": 3750.00,
"Premium": 3900.00
} [...] }
The Default
key defines the default price for all users.The Vip
key defines a special price for VIP users.The Premium
key defines a price for Premium users. -
Make sure you’ve created the custom dictionary field in your Coveo organization, and that:
-
The field is set as a dictionary field by enabling the
keyValue
option. -
You created the source mapping that links your product metadata (for example,
price_list
) to the custom field in your Coveo organization.
-
-
Update your search configuration to include the custom dictionary field in the
additionalFields
array. For example:{ [...] "queryConfiguration": { "additionalFields": [ "price_list" ] } [...] }
-
Configured search token authentication to include, in the
dictionaryFieldContext
object, the user information needed to extract the correct price from the dictionary field. For example:{ [...] "dictionaryFieldContext": {"price_list": "Vip"} [...] }
This allows Coveo to extract the proper price value from the
price_list
dictionary field based on the visitor’s context at query time. -
Make sure to use your custom dictionary field (for example,
price_list
) in all customer-facing interfaces to ensure that visitors see the correct price. This prevents the fallback value from theec_price
field, which may not reflect buyer-specific pricing, from being displayed. You’ll typically want the following features to rely on the value of the dictionary field:-
Result templates
-
Facets and sorting
-
Attributes to define merchandising rules in the CMH.
-
Step 2: Index the ec_price
field with a fallback value
To ensure that the ec_price
field is indexed, you must still provide a fallback value.
For example, you could use a static price such as the manufacturer’s suggested retail price (MSRP) or an average price.
This value will be used by Coveo ML models and other features that rely on the ec_price
field.
For ec_price
to be indexed as a fallback value:
-
Make sure that your catalog product data is configured to index the
ec_price
field. For example, your product data could look like this:[...] { [...] "documentId": "product://001-red", "ec_product_id": "001-red", "ec_price": 28.00,
"objecttype": "Product", [...] }, [...] { [...] "documentId": "product://002-blue", "ec_product_id": "002-blue", "ec_price": 32.00,
"objecttype": "Product", [...] }, [...]
The ec_price
field is indexed with a fallback value. -
Make sure that your catalog configuration in your catalog entity maps the pricing metadata to the
ec_price
field.
Strategy 2: Index a fallback price
If you can’t index all possible prices for a product, or if the pricing logic is too complex to represent as dictionary keys, you can store a fallback value in the ec_price
field.
For example, you could use a static price such as the manufacturer’s suggested retail price (MSRP) or an average price.
This value will be used by Coveo ML models and other features that rely on the ec_price
field.
This strategy will require you to fetch the actual price from an external system at query time.
For ec_price
to be indexed as a fallback value:
-
Make sure that your catalog product data is configured to index the
ec_price
field. For example, your product data could look like this:[...] { [...] "documentId": "product://001-red", "ec_product_id": "001-red", "ec_price": 28.00,
"objecttype": "Product", [...] }, [...] { [...] "documentId": "product://002-blue", "ec_product_id": "002-blue", "ec_price": 32.00,
"objecttype": "Product", [...] }, [...]
The ec_price
field is indexed with a fallback value. -
Make sure that your catalog configuration in your catalog entity maps the pricing metadata to the
ec_price
field.
Strategy 3: No indexing
If you can’t index the ec_price
field at all, you can choose to leave it out entirely.
However, you won’t be able to use the following:
-
The Coveo ML Session-Based Product Recommendations (SBPR) model or the Cart recommender strategy of the Product Recommendation (PR) model.
-
The price attribute in merchandising rules.
-
Price values for filtering or sorting in Coveo-powered interfaces.
-
Price values in search result templates.
This strategy will require you to fetch the actual price from an external system at query time.
About reporting
Coveo’s revenue-based reporting features, such as CMH reports and Advanced Reports in the Administration Console, don’t rely on the indexed ec_price
field.
Instead, they calculate revenue based on the price value provided in purchase events.
As long as your purchase events include the price actually paid by the customer, revenue reporting will work as expected, even if you don’t index the ec_price
field.
See Log commerce events for more information on usage analytics tracking in Coveo for Commerce.