---
updatedAt: 2025-10-31T12:04:14.000Z
agentTools:
  projectIndex: https://docs.rejoiner.com/llms.txt
---

# Recommendations

# Leveraging Product Recommendations

Recommendations are made up of the best selling, most viewed, and newest products across your entire catalog as defined by your customer's purchase behavior.

Our recommendation algorithm predicts what products your customers are most likely to buy next and intelligently serves these items in your email creative. We've made it very easy to recommend products based on browse activity and cart data to help you increase your CTR and revenue per email.

# Configuring Recommendations

We've made it very simple to manage your recommendations in the application via your Account Settings.

There you will be able to configure the following:

1. **Aggregation Timeline (days back):** This setting allows you to manage the timeframe which the app should consider in order to define your catalog's top sellers.

2. **Products to Exclude:** this setting is useful for suppressing items that you do not want to recommend.

<Image
  alt="Screen_Shot_2021-02-09_at_8_21_52_PM.jpg"
  border={false}
  caption=""
  src="https://files.readme.io/35e4174-Screen_Shot_2021-02-09_at_8_21_52_PM.jpg"
  width="2806"
/>

### Aggregation Timeframe

This setting helps us determine the timeframe you'd like to use for your product recommendations.

The default is *All Time* where we look at your all-time products. You are able to change this setting to a more fitting timeframe depending on your business type and product catalog.

So for example, if you would like your `top_sellers` recommendations to reflect the last month **only**, you should select the timeframe of *Last Month* to make sure that we're injecting the overall top sellers of the last 30 days.

After making your selection **you will need to save** your recommendation settings.

### Excluding Products

You can suppress certain items that you do not wish to feature in your recommendations.

1. Go into the *Product Exclusions* section of your Recommendation Settings.

2. Start by typing the product `product_id` (SKU) you wish to suppress. A list of available items under the `product_id` you type in the search will populate to help you make a selection.<br /><br />You can either select from the list or add a product to the suppression list by typing the `product_id`. Note that the list is case-sensitive.

<Image
  align=""
  alt="recos-exclude-dd.png"
  border={false}
  caption=""
  src="https://files.readme.io/0fc6247-recos-exclude-dd.png"
  width="400"
/>

The product information of the items you suppress will be visible in your *Excluded Products* list. You can always click on the `x` next to the product tag in order to remove the product from the suppression list.

<Image
  align=""
  alt="recos-exclusions.png"
  border={false}
  caption=""
  src="https://files.readme.io/a2754bc-recos-exclusions.png"
  width="400"
/>

<Callout
  type="warning"
  body="The product exclusion feature will only auto-populate for products that have been viewed."
/>

3. Once your suppression list is ready, you'll need to save your recommendation settings. Otherwise, you will lose your changes.

### Extract Product IDs/Categories

Products are generally injected into the template as a list of items, whether that comes from `recommendations`, `cart items`, or `viewed items`. There are several additional filters and tags which accept a comma-separated list of product ids or categories.

To allow for using these lists of items as parts of these filters, the following two filters are available:

1. `extract_product_ids`
2. `extract_categories`

These can be used like so:

<label class="code-label">Example Usage</label>

```
# Get the site top sellers from the same categories as the customer's cart items:
{% recommendations "top_sellers" use_cart=True as top_sellers %}

# Get items viewed together with items the customer viewed, excluding the top-sellers from the previous recommendations:
{% recommendations "viewed_together" use_browsed=True exclude_product_ids=top_sellers|extract_product_ids|join:"," as viewed_excluding_top_sellers %}
```

<br />

# Recommendation Taxonomies

Product recommendations have different types, which we will refer to as "taxonomies." Below is a listing of the types available, their definition, and their type usage.

| Taxonomy               | Parameter Value        | Description                                                                               |
| ---------------------- | ---------------------- | ----------------------------------------------------------------------------------------- |
| **Top Sellers**        | `"top_sellers"`        | Injects the top selling products from your entire catalogue or from specified categories. |
| **Most Viewed**        | `"most_viewed"`        | Injects the most viewed products from your entire catalogue or from specified categories. |
| **Purchased Together** | `"purchased_together"` | Injects products that are frequently purchased together with specified products.          |
| **Viewed Together**    | `"viewed_together"`    | Injects products that are frequently viewed together with specified products.             |
| **New Products**       | `"new_products"`       | Injects recent products filtered by a timeframe or setting.                               |

# Recommendations Template Tag

The recommendations template tag is very flexible and powerful and should be able to provide you with the ability to insert some recommended products based on your specifications. The template tag has one required parameter which is the taxonomy as described in the [section above](#recommendation-taxonomies).

Additionally, the template tag should *always* end with `as VARIABLE_NAME`. The variable name can be whatever you want, however, the recommendations tag will not be able to be used without it.

<label class="code-label">Basic Example: Global Top Sellers</label>

```
{% recommendations "top_sellers" as recommended_items %}
```

After including the above tag in your template, you are now able to include data from recommended products documented in the [Template Tag Attributes](#template-tag-attributes) section.

Additionally, the `recommendations` tag takes several options that **are not required, but provide enhanced capabilities**.

<br />

<Callout
  type="warning"
  body="Keep scrolling to the right of the table below for more option details"
/>

| Option                | Description                                                                                                                                                                                                                                                                | Type                                | Example               |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | --------------------- |
| `use_cart`            | **For Top Sellers and Most Viewed:**<br />only include products in the same categories as the customer's cart items.<br /><br />**For Purchased Together and Viewed Together:**<br />Only include products purchased or viewed together with the customer's cart items.    | `True`/`False`                      | `False` (Default)     |
| `use_browsed`         | **For Top Sellers and Most Viewed:**<br />Only include products in the same categories as the customer's viewed items.<br /><br />**For Purchased Together and Viewed Together**<br />Only include products purchased or viewed together with the customer's viewed items. | `True`/`False`                      | `False` (Default)     |
| `exclude_cart`        | Exclude the customer's cart items from the recommended items.                                                                                                                                                                                                              | `True`/`False`                      | `True` (Default)      |
| `exclude_browsed`     | Exclude the customer's viewed items from the recommended items.                                                                                                                                                                                                            | `True`/`False`                      | `True` (Default)      |
| `exclude_product_ids` | Exclude specific `product_id`s (SKUs) from the recommended items.                                                                                                                                                                                                          | Comma separated list of product IDs | `"SKU-01,SKU-02"`     |
| `exclude_categories`  | Exclude products with the specified categories from the recommended items.                                                                                                                                                                                                 | Comma separated list of categories  | `"gifts,clearance"`   |
| `categories`          | Only include products with the specified categories from the recommended items.                                                                                                                                                                                            | Comma separated list of categories  | `"category,name"`     |
| `categories_and`      | Queries for products containing ALL categories. If False; filters products with at least one of the categories passed in `categories`                                                                                                                                      | `True` / `False`                    | `False` (Default)     |
| `product_ids`         | For *Purchased Together* and *Viewed Together*, include products related to these specific `product_id`s                                                                                                                                                                   | Comma separated list of product IDs | `"SKU-01,SKU-02"`     |
| `count`               | The number of recommended products to retrieve                                                                                                                                                                                                                             | Number                              | `3` (Default)         |
| `days_back`           | Injects products that are active in the past `days_back` days                                                                                                                                                                                                              | Number                              | Setting (`days_back`) |
| `price_above`         | Filter products whose price is bigger than the value `price_above`                                                                                                                                                                                                         | Number                              |                       |
| `price_below`         | Filter products whose price is lower than the value `price_bellow`                                                                                                                                                                                                         | Number                              |                       |

<label class="code-label">Complex Examples:</label>

```
# Top Sellers in the same categories as cart items
{% recommendations "top_sellers" use_cart=True as recommended_items %}

# Products Purchased Together with cart items, including products the customer viewed
{% recommendations "purchased_together" use_cart=True exclude_browsed=False as recommended_items %}

# 6 Most Viewed Products in a specific category excluding a specific product id
{% recommendations "most_viewed" categories="vip-items" exclude_product_ids="super-vip-item" count=6 as recommended_items %}
```

### Template Tag Attributes

The `recommendations` tag above registers an array of products into the variable name you defined in the template tag (`as VARIABLE_NAME`). Each of these products have the following attributes that you are able to insert into your template. The table below assumes you have a product in the variable `item` by doing something similar to the following:

```
{% recommendations "top_sellers" as recommended_items %}
{% for item in recommended_items %}
Use {{ item.TAG }} here...
{% endfor %}
```

| Tag           | Usage                               | Description                     |
| ------------- | ----------------------------------- | ------------------------------- |
| `name`        | `{{item.name}}`                     | Product Name                    |
| `price`       | `{% display_currency item.price %}` | Product Price                   |
| `product_url` | `{{item.product_url}}`              | Product URL                     |
| `image_url`   | `{{item.image_url}}`                | Product Image URL               |
| `description` | `{{item.description}}`              | Product Description             |
| `categories`  | `{{item.categories}}`               | Array of Product Category Names |
| `product_id`  | `{{item.product_id}}`               | Product ID (SKU)                |

# Using Recommendations in Email Creative

## 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.

<img src="https://drive.google.com/thumbnail?id=1-Js4YrmIbqQXZSIPjiT3XKgwzQmSDLiS&sz=w{{400}}"  />

<Callout
  type="warning"
  body="Create your recommendation sections as Snippets. That way you can re-use your recommendations code in more than one email creative."
/>

<label class="code-label">Simple example of a recommendation tag:</label>

```
{{recommendations.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.

<label class="code-label">Sequencing Examples:</label>

```
// First Item
{{recommendations.category_top_sellers.0.name}}

// Second Item
{{recommendations.category_top_sellers.1.name}}

// Third Item
{{recommendations.category_top_sellers.2.name}}
```

<br />

## Usage and Process

1. First you want to select your recommendation type. In this example, we'll use <code>purchased\_together</code>.
   <br />

We will also be injecting 4 recommendations and because we're hardcoding the structure, we want to use an if statement with the correct tag type and index of product in order to only inject the structure when the recommendation exists. <br />

<label class="code-label">Start of Conditional</label>

```
{% if recommendations.purchased_together.0 %}
```

2. Next, we want to add the merge tags/product information we want to show. We'll start by injecting the  image:
   <br />

```
<img style=”max-width: 104px; border: none;” src=”{{recommendations.purchased_together.0.image_url}}” alt=”{{recommendations.purchased_together.0.name}}” />
```

<Callout
  type="warning"
  body='You will want to make sure that we add a maximum width to the images. You may also want to add the product name in the <code>alt=""</code> 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:

<label class="code-label">End of Conditional</label>

```
{% endif %}
```

Since 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.

### Purchased Together and Viewed Together

These `recommendation_type`'s require a mandatory option `product_ids` in order to work. Since we want to show a relation of products we need to specify a base on `product_ids`.

<label class="code-label">Purchased/Viewed Together:</label>

```
{% recommendations "purchased_together" product_ids="prod1-SKU,prod2-SKU" as related_products %}
  {% for product in related_prodcuts %}
    <li>{{product.name}}</li>
  {% endfor %}
```

**Example of End Result:**

<iframe
  src="https://codepen.io/rejoiner/embed/VXqJKO/?height=265&theme-id=dark&default-tab=html&embed-version=2"
  height="350"
  width="100%"
  frameBorder="0"
  allowTransparency={true}
  allowFullScreen={true}
/>

<br />

### 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 catalog. We recommend implementing a *fail-safe* via a conditional regardless of the method you use to structure your recommendations.

For example, if you were to recommend *Products Frequently Purchased Together* and your customer added a new product in your catalog 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 basic conditional that states that `if` there are matches for `X` recommendation taxonomy, show these, `else` replace recommendations with `Z` taxonomy.

<br />

**Note that fail-safe usage is only applicable when recommendations are using the following taxonomies:**

1. Products Viewed Together
2. Browsed Category Top Sellers
3. Products Frequently Purchased Together
   4.Category Top Sellers

<Callout
  type="warning"
  body='It is highly unlikely – if not impossible – that Rejoiner wont generate recommendations for your Overall Top Sellers. For that reason, we recommend using the top_sellers taxonomy as your go-to 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.

The code below can be used as a guide for fail-safe usage. In this example,  we're going to substitute `purchased_together` items with `top_sellers` if there are no matches.

<label class="code-label">Fail Safe Structure Example:</label>

```
<!-- START Fail Safe Conditional -->
//If there are purchased_together recommendations
{% if products.purchased_together %}

<!-- PURCHASED TOGETHER RECOMMENDATIONS HTML -->

// Else, if there are no matches, show top_sellers
{% else %}

<!-- TOP SELLERS RECOMMENDATIONS HTML -->
{% endif %}
<!-- END Fail Safe Conditional -->
```

**In the end you will end up with something like the example below:**

<iframe
  src="https://codepen.io/rejoiner/embed/OvdLbd/?height=265&theme-id=dark&default-tab=html&embed-version=2"
  height="350"
  width="100%"
/>

> **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:

<label class="code-label">Fail Safe Structure Example:</label>

```
<!-- START Fail Safe Conditional -->
//If there are purchased_together recommendations
{% if products.purchased_together %}

<!-- PURCHASED TOGETHER RECOMMENDATIONS HTML -->

{% endif %}
<!-- END Fail Safe Conditional -->
```

### Excluding Injected Items

There will be times where you do not want to include products that may have been injected in another section of your email—like the products your customer abandoned—in the recommendations. To avoid scenarios like these we use exclude filters.

> To learn more about exclusion filters and how to use them go to [this tutorial ](https://docs.rejoiner.com/docs/template-tags#exclude-products).