Recommendations Injection

This tutorial is for those who want to inject product recommendations in their HTML email templates.

In This Article

 

Strict Injection Method

In order to establish a rigid structure, you need to know the number of items you want to inject. Then, you will start counting your items from ZERO. Next, you'll add the order of the product within the structure of your recommendation tags – which you can see below.

Simple example of a recommendation tag:

{{products.category_top_sellers.0.name}}

Again, the listing of recommended products starts with ZERO, so you can use the logic below to further structure your recommendations. 

  • The FIRST product’s listing is = 0

    {{products.category_top_sellers.0.name}
  • The 2ND product listing is = 1

    {{products.category_top_sellers.1.name}}
  • The 3RD product listing is = 2

    {{products.category_top_sellers.2.name}}
  • The 4TH product listing is = 3

    {{products.category_top_sellers.3.name}}

Etcetera

 

Usage and Process

1
To beging coding, we must (first) use an if statement with the correct tag type and  index of  product. In this case, the recommendation type we'll use as an example is for Products Frequently Purchased Together:

{% if products.purchased_together.0 %}
View all recommendation types  here
2
Next, we want to add the merge tags / product information we want to show. We'll start by injecting the  image:

<img style=”max-width: 104px; border: none;” src=”{{products.purchased_together.0.image_url}}” alt=”{{products.purchased_together.0.name}}” />
Note: You will want to make sure that we add a maximum width to these images.We also want to add the product name in the alt=” ” property.
3
Next, we want to add the name below the image:

{{products.purchased_together.0.name}}
4
Next, we want to hot-link the image and the product name to the product page like so:

<a href=”{{products.purchased_together.0.product_url}}” target=”_blank”>LINK TEXT HERE</a>
5
Lastly, we want to close the if statement using the tag below:

{% endif %}

As we're implementing a rigid structure, you'll want to repeat the steps above for every item you want to inject. 

So if you want to inject 4 items, you'll repeat these steps four times. For an example of the end-result of this process, see below:

Example **

** This example is just for demonstration purposes, not a template.

 

Fail-Safe Scenarios

Though our application's recommendation algorithm will match other product recommendations to a product there will be times where we can't generate a match. These are edge cases such as when the item to match is a new addition to your product catalogue. We recommend to implement a fail-safe via a conditional regardless of the method you use to structure your recommendations.

This is due to the fact that you may add special styling or an introductory text to your recommendations. So if we cannot generate a match, you will be left with a row of text in your email that shows no products. Thus, leaving a bad impression.

So for example, if you were to recommend Products Frequently Purchased Together and your customer added a new product in your catalogue to their cart. There's a chance this new product may no trigger any recommendations. Therefore, the best scenario is to substitute the  purchased_together recommendations section with top_sellers

You can easily do this via a conditional that states that IF there are matches for X recommendation taxonomy, show these, ELSE replace recommendations with Z taxonomy. 

Note that fail-safe usage is only applicable when recommendations are using the following taxonomies: 
  • Products Viewed Together
  • Browsed Category Top Sellers
  • Products Frequently Purchased Together
  • Category Top Sellers
Note: It is highly unlikely – if not impossible – that Rejoiner won't generate recommendations for your Overall Top Sellers. For that reason, we tend to recommend using this type as your fail-safe.

Below you will find steps to create a fail-safe conditional that will automatically switch the recommendation taxonomy in order to guarantee that your recommendations section is bullet-proof.

In this case, we're going to substitute category_top_sellers items with top_sellers if there are no matches.

1
If there are no purchased_together items to match 
{% if products.purchased_together %} <!-- CATEGORY TOP SELLERS RECOMMENDATIONS HTML -->
2
THEN replace with top_sellers 
{% else %} <!-- TOP SELLERS RECOMMENDATIONS HTML -->
3
End conditional. 
{% endif %}

At the end you will end up with something like this:

Note: You must make sure that each section uses the correct structure as delineated by the Strict Injection Method steps above.

Another option is to completely hide the whole recommendations section if there are no matches. 

To do this you will just need to add the first part of the conditional statement and the closing tag to end the statement so that it reads like:

1
If there are no category top sellers to match – hide the section 
{% if products.category_top_sellers %}
2
End conditional: 
{% endif %}

To help you we've generated the fail-safe conditionals snippets below for every recommendation type:

<!-- Products Viewed Together -->

<!-- start conditional -->
{% if products.viewed_together %}
<!-- section HTML -->
{% endif %}
<!-- end conditional -->

<!-- end section -->
<!-- Browsed Category Top Sellers -->

<!-- start contional -->
{% if products.browsed_category_top_sellers %}
<!-- section HTML -->
{% endif %}
<!-- end conditional -->

<!-- end section -->
<!-- Category Top Sellers -->

<!-- start conditional -->
{% if products.category_top_sellers %}
<!-- section HTML -->
{% endif %}
<!-- end conditional -->

<!-- end section -->
<!-- Products Purchased Together -->

<!-- start conditional -->
{% if products.purchased_together %}
<!-- section HTML -->
{% endif %}
<!-- end conditional -->

<!-- end section -->

 

Exclude Injected Items

Exclude filters are powerful builtins part of the Rejoiner templating language. You will only be needing an exclusion filter when implementing several injection types at once. Thus, if you are planning to inject product recommendations along cart or browsed data, we recommend using exclusions in order to avoid duplicates.  Learn how to use exclusion filters here.

Still need help? Contact Us Contact Us