Skip to content

Recommendation templates

Each Recommendation has a design associated with it. Multiple recommendations can be associated with the same design. When the recommendations are returned in HTML format, the selected design will render the content.

Input tags

The recommendation liquid templates have a special input tag. With the syntax

{% input headline %}

In the template, this behaves like printing a liquid variable, but the variable's value will be provided by the actual recommendation that the design is being used by. This makes it possible to reuse the same design on multiple recommendations but, for instance, still have separate headlines provided by each recommendation.

Liquid context

When implementing the design you have the following variables available in the liquid context.

Variable Description
products The list of recommended products found by the configured recommendation algorithm. Typically you would loop over this list and render each product. The items in the list are product objects. See description in the introduction
sources An alternative way of looking at the recommended products. Sources is a list of objects. Each object contains the properties name, count and products. There is one object for each step in the configured recommendation algorithm that was executed. The name can be used to recognize what algorithm was used in that step, the count indicates how many products were found in the step, and products is a list of products found by that step. This can be useful if you want to handle products from different steps in different ways. The items in the list are product objects. See description in the introduction
contextProducts A list of products that provide the context the recommended products are found within. These are based on the input url, urls or productNumbers included in the API call. Each item in the list is a product object. See description in the introduction
currentProduct The product found based on the input url given. If no url is provided it will contain the first element from the contextProducts list
key The string key of the recommendation being rendered
priceFormat The price format configured on the website
context A dictionary containing the values passed to the API call in the context parameter. These are the values that are also typically used to filter on in the recommendation algorithm sources