Advanced Personalization: Using Metafilters

Advanced Personalization: Using Metafilters

Metafilters are business rules that you can apply when you build your emails, to rule out certain types of content.

Let’s say you have a customer who you know has just bought a blender from your online store.

Chances are, they don’t want to see Blenders again for a while after all that research, narrowing down and buying. So what you can do is eliminate content that contains ‘blenders’ from the email content of any user who has just bought a blender. You can pretty much eliminate content that any user just bought from any personalized content you send to them. This is a more advanced way to personalize your email content.

HOW IT WORKS

SECTION SPECIFICATION

In the body of an email that will use filters, each section of an email should be defined with a tag as follows:

{% recommendation <section_name> | count: <num> | filter: ‘<name>’, ‘<op>’, ‘<value1>|<value2>|…’ | … %}

Section Specification ExamplesEach filter will be combined with other filters. The <op> stands for ‘operator’. Leaving it blank will default to ‘equals’. Pipe-separated values combine multiple filters using ‘OR’ statements.

// Returns 5 articles that are of resource type “article” and contain either “featured” or “promoted” in the “category” field.
{% recommendation featured_and_promoted_articles | count: 5 | filter: ‘resource-type’, ‘, ‘article’ | filter: ‘category’, ‘, ‘featured|promoted’ %}

// Returns 10 resources that have both “dogs” and “cats” in the keywords field.
{% recommendation dogs_and_cats | count: 10 | filter: ‘keywords’, ‘, ‘dogs’ | filter: ‘keywords’, ‘, ‘cats’ %}

// Returns 2 resources that have a pubDate in the last 7 days.
{% recommendation this_week | count: 2 | filter: ‘pubDate’, ‘AFTER’, ‘-P7D’ %}

// Returns 5 resources that are not of the ‘event’ resource type.
{% recommendation non_events | count: 5 | filter: ‘resource-type’, ‘NOT’, ‘event’ %}

// Returns 5 resources that have “region” either “global” or equal to the user’s user_region attribute
{% recommendation local_or_global | count: 5 |filter: ‘region’,’,’global|{{user_region}}’%}

Upon rendering, section specification tags are replaced with the empty string and will therefore not render. To be safe, it is likely best to comment out the tags:

<!–
{% recommendation non_events | count: 5 | filter: ‘resource-type’, ‘NOT’, ‘event’ %}
{% recommendation this_week | count: 2 | filter: ‘pubDate’, ‘AFTER’, ‘-P7D’ %}
–>

DYNAMIC MERGE TAGS

When an email contains a section specification tag as above, merge tags take a new syntax in the following format:

{{<section_name>.<index>.<field>}}

where <section_name> is the name specified in the section specification; <index> is the index of the recommendation (starting at the first recommendation in index 0), and <field> is the dynamic field to insert as text.

The dynamic merge tag format you may be used to ( {{rec.<resource-type>.<index>.<field>}} ) is still available, but should only be used when no filters are required.

Merge Tag Examples

// Returns the title of the first featured_and_promoted_articles.
{{ featured_and_promoted_articles.0.title }}

// Returns the thumbnail src of the 2nd recommendation in the this_week section.
{{ this_week.1.thumbnail }}

// note this will need to be inserted into an <img> tag to render the image.
<img src=”{{ this_week.1.thumbnail }}” />

Remember:

Metafilters are inherently risky. Using very tight metafilters will ultimately limit our platform’s ability to provide great personalized results and CTOR improvements for customers, though they are sometimes necessary.

As well, while we always try our best to support metafilters provided in a request, they are the first filters relaxed when for any reason we are unable to get enough recommendations.

In general it is best to apply global filters to set your business rules. To do this, Contact ZetaHub Support 

Is this article helpful?
Share this article
Skip to toolbar