Einstein recommendations: Scenarios

Your recommendation engine in Salesforce Marketing Cloud – Part 2


In part 1, we looked at the set-up of Einstein (formerly known as Personalization Builder). Part 2 explains how to use it for different scenarios, ruling, and integration in email and web.

Salesforce Einstein recommentations





Please note: this process includes multiple highly technical steps. We encourage marketers to read through this article carefully so you understand what’s needed, and to pull in a Marketing Cloud developer for the more complicated steps, especially the integration part.

How to continue from the setup

Marketing Cloud starts collecting data immediately after you implement the Collect Code on your website. When would be a good moment to start checking your recommendations? That depends on the amount of traffic.

Salesforce Marketing Cloud Personalization Builder


Follow the steps below to assess the status of your data collection and to start building your recommendation scenarios:

Step 1

In Marketing Cloud go to EinsteinWeb Recommendations and click on Reporting.

Salesforce Marketing Cloud Personlization Builder

When you click on Contacts you will be able to select your own profile (based on your local cookie), load a random profile (identified or anonymous) or search for a specific customer through the customer key (it states email in the label, but this should be the key used in the Collect Code script on your website). Loading a profile will give you the insights in the exact behavior of your visitor and their affinities. This is a very useful way to test your data collection and to monitor the behavior of your collect codes.

Salesforce Marketing Cloud Personalization Builder

Next is the buildup of the user affinities. This is linked to your product catalog, where you do the actual mapping and what fields have been marked for tagging. Make sure you choose your fields wisely, your scenarios and recommendations are going to be built around these affinities and should make sense for your line of business. In the case below, we picked categories and brand as affinity attributes. This is a best practice for a retailer. If you have info in your product catalog that creates useful affinities for recommendations, just tag it (For example: preferred color or shoe size).

Salesforce Marketing Cloud Personalization Builder

If you have built scenarios in email recommendations, these will be displayed for the customer that you searched for.

Step 2

In Marketing Cloud go to EinsteinWeb Recommendations and click on Overview.


Now the fun part begins. In this section you are going to set up your recommendation scenarios. Einstein comes with a lot of pre-defined out-of-the-box recommendation scenarios. Which one to pick? That all depends on your use case and what you want to achieve.

example of a static image generated by email recommendation

But why Web Recommendation? Aren’t we going to use Email Recommendations at all? No, and here’s why: We advise not to use the Email Recommendation part, because of the output these scenarios generate. The output of an Email Scenario is a fixed image. This image includes all content to be used in an email (header, price, image, text, call to action etc.). If we integrated image recommendations into an email, we would get multiple images in the email, and we can only measure a one-click on the total image. If images are blocked by the subscriber, the email would display empty. In today’s email marketing best practices and design, this kind of setup is not recommended.

What does Web Recommendation do that is better practice for email and web? The answer is: JSON feeds. Developers love JSON feeds, JSON is simpler to read and write than XML, and it’s less prone to bugs. JSON can be used in email and web to execute the defined scenarios. So, let’s build a scenario and show you how to use this in an email.

When creating a new recommendation, Einstein offers the options to use the out-of-the-box scenarios for several web pages. This easy setup of scenarios is already useable for the web. Start with the Home Page and Product scenario for your website and create a new page to be used in your emails.

Homepage scenario

To set up your Homepage Scenario, drag and drop the scenarios on the canvas, don’t forget to check the Waterfall box and to determine the most efficient order.

Obviously, this will require some testing and optimization. The output has a lot of dependencies, such as the data collected about behavior, rules that you want to apply and the order of scenarios. If you check the Waterfall, multiple scenarios are executed in the given order. This will ensure that the number of recommendations that you have defined is completed.


Finally, define the layout of your recommendation and the export format in JSON and get the code to be used on the Homepage of your website.

Below is the code for your web recommendations. You, or a web developer, will need to style the rendered HTML to match your website’s style.

<!– Copy this code right before the closing </body> of your home page–>
<script src=”https://1234567.recs.igodigital.com/a/v2/1234567/home/recommend.json” type=”text/javascript”> </script>

Product scenario

For the product scenario, follow the same procedure as for the homepage. The main difference is, that this needs to be placed on the page for a particular product, so up-and cross sell products can be executed and integrated on your page.

The JavaScript code is slightly different:

<!– Copy this code right before the closing </body> of your product page–>
<script src=”https://1234567.recs.igodigital.com/a/v2/1234567/product/recommend.json?item=sku” type=”text/javascript”> </script>

On the product page, you need to populate the SKU of the product in the JavaScript call to get personalized recommendations for this product.
You can build similar scenarios for search, category and cart.

Email scenario

As we mentioned, you will not be using the email recommendation part in Einstein. You build this scenario in the web recommendation part (please note that web recommendations are only available in corporate or enterprise license of Marketing Cloud).

For this scenario, create a new web page and call this Mail (or any other name, as long as it’s clear to you). For integration in email you will need to build a scenario that is linked to the use case of your email. For example: Do you want recommendations in your newsletter, or based on recent product behavior on your website. Again, this will require use case discovery and lots of testing, you will not have optimized results and finish this setup in a couple of hours.

A good general setup for email is the below scenario order:

Salesforce Marketing Cloud Personalization Builder

Get the JavaScript code:

<!– Copy this code right before the closing </body> of your mail page–>
<script src=”https://1234567.recs.igodigital.com/a/v2/1234567/mail/recommend.json” type=”text/javascript”> </script>

Then add ?email= and ?item=sku to the url and populate this in the email with the SubscriberKey and SKU that is used in your Collect Code. This will enable personalized recommendations for your subscriber, combined with the product viewed by your subscriber (needs to be in the data extension used for sending this email).

How to use this JavaScript in an email

The nice thing about JSON feeds is that we can ‘read’ them via GTL and process via Ampscript. Your JSON feed contains the number of products that you defined in your recommendation scenario and needs to be ‘looped’ and processed into individual Ampscript variables for displaying the necessary fields in your email.
Here’s an example that can be used in email:


set @key = AttributeValue(“_subscriberkey”)
set @sku = AttributeValue(“SKU”)
set @Count = 0
set @URL = https://1234567.recs.igodigital.com/a/v2/1234567/mail/recommend.json?email=
set @URL_extra = “?item=”
set @finalURL = CONCAT(@URL,@key,@URL_extra, @SKU)
set @JSON = HttpGET(@finalURL)

{{.datasource JSONVar type=variable maxRows = 1}}


            { “target” : “@Json” }

{{.datasource JSONItems type=nested maxRows = 6}}


            { “target” : “JsonVar.Items” }



SET @Count = ADD(@Count, 1)

IF @Count == 1 THEN

   set @Prod = TreatAsContent(“{{JSONItems.product_code}}”)

   set @link = TreatAsContent(“{{JSONItems.link}}”)





Step 3

The final step to optimize, is setting up the Rule Manager. The Algorithm of Einstein could potentially give unwanted recommendations or combinations that you may want to manage yourself. You will want to be able to change and influence the recommendations that the scenarios produce, basically building up a weight factor.

Some examples:

  • Only show products that are in Sale or in stock
  • Only show products with a sales price higher than 20 Euros
  • Don’t show tv’s when the product viewed is a refrigerator

Use the Rule Manager to build rules linked to particular scenarios. The actions you can use are:

  • Emphasize items, this will increase the Weight of a product, making it more eligible to be shown in a recommendation
  • Include items, force items to be included in a recommendation
  • Exclude items, force items to be excluded from a recommendation
  • Inject a particular SKU in a recommendation
  • Allow (only x), this helps you to influence the number of items you want to display in a recommendation string with a particular category, color, size, brand etc. The items you can pick depend on what is available in your product catalog
  • Allow (only x of any), you can force a recommendation to show only for example 4 items from any brand or category

Play around a bit with these rules, but take care you don’t end up with zero recommendations because you defined too many or conflicting rules. Don’t forget to test the recommendations and the output.

How do you test this?

You can simply execute the JSON feed in your browser and check out the results, or use a free JSON Viewer.

If you would like to experience the results of Einstein recommendations, take a look at the Blokker website.

If you need more information about, or help with, the Salesforce Marketing Cloud and Einstein, our certified experts would love to help you out. Feel free to contact us.