Recommendations

Overview

Taking advantage of machine learning-powered recommendations for your content can be achieved with the Recommendation tag.

Recommendations Tag

Example

{% recommendation articles | count: 3 %}

This tag creates a variable called ‘articles’ and assigns it an array of resource objects based on the entered count, in this case, three. The number of recommendations you retrieve should be the number of resources you will utilize in your content.

You can add the tag and the array created anywhere your content. The contents of the returned array can be viewed in content using {{articles}}, or you can populate the contents of the resources with the syntax {{articles[0].title}}.To narrow recommendations to specific types of resources or based on other metadata, you can add filters.

Filtered Recommendation Tag

Example

{% recommendation articles | count: 3 | filter: 'resource-type', '', 'article' %}

This tag includes a filter for the metadata of resource-type with a value of ‘article’.

Additional filters, such as user properties, can be added by separating them with a pipe.

Example

{% recommendation dogs_and_more | count: 5 | filter: 'keywords', '', 'dogs' | filter: 'keywords', '', '{{animal_preference_2}}' %}

Filter operators (=, CONTAINS, NOT, AFTER, BEFORE, BETWEEN) can be inserted as needed in the empty string after the name of the meta tag you want to filter on. An empty string (no operator specified) is treated the same as having equality ('=').

Example

The filter {"name":"keywords", "values":["dogs", "cats"]} will filter to resources that contain either “dogs” or “cats” as a keyword.

The filter {"name":"color", "values":["red"]} will filter to resources with the color field set to “red”.

Filtered Contains Tag

Example

The Filter % recommendation example-cars | count: 3 | filter: ‘resource-type', ‘=', ‘product' | filter: ‘brand’, ‘CONTAINS’, ‘General’ %}

For a list of resources, it’s similar:

Example

{% resources example-autos | count: 3 | filter: ‘resource-type', ‘=', ‘product' | filter: ‘brand’, ‘CONTAINS’, 'Motors’ | sort_field: 'start_date' | sort_order: 'asc' %}

The available operators for both of these in email are documented in the table below:

Operator

Description

’=’ (EQUALS)

Can also be empty quotes ‘'

‘CONTAINS’

Includes the provided value as a portion of the field value.

‘NOT'

Does not equal

'BEFORE'

Prior to the time period relative to the current date (3 days ago, 7 days from now, etc.)

Only works with valid date fields

'AFTER'

After a time period relative to the current date (3 days ago, 7 days from now, etc.). Only works with valid date fields.

‘BETWEEN’

Between two time periods relative to the current date (between 3 days ago and 7 days from now, etc.). Only works with valid date fields.

You can read more about Operators here.

  • Filtering could reduce the quality of personalization. The Recommendations engine will override the filter if it cannot retrieve the requested number of recommendations.

  • The filter names are all dependent on the available resource fields. If a resource has an author, you can filter by it. If not, it doesn’t work.