Before you start, why not watch this short video about web recommendations?

In order to use Predict recommendations, you need the Emarsys JavaScript API implemented on your website.

When you request recommendations through this API, with the help of the recommend command, you have to specify:

  • The recommendation logic you want to use.
  • The number of products to display in widget.
  • ID of the DOM element where the recommended products should be rendered. This DOM element needs to exist already when the recommend command is issued.
  • the template to use to render the recommended products, either directly or through the ID of the DOM element containing its text. The template should conform to the doT.js template syntax.

In addition, you can specify:

  • A baseline of product IDs if you want to compare the performance of the Predict recommendations to an existing recommender.
  • A success handler which will be invoked before the recommended products are rendered. This way you can freely modify the set or order of recommended products, or their data. You may even decide not to render the recommended products in certain situations.
  • The language in which to render the recommended products (in the case of supported widgets).
  • Whether recommend is invoked from a test or staging environment, and as a consequence should not be logged on the Predict servers.

Moreover, the Predict JavaScript API provides other commands which, when issued before recommend, can be used to instruct Predict to recommend only products which

  • are in a specific availability zone,
  • meet specific criteria based on product catalog properties (e.g. category),
  • do not meet specific criteria based on product catalog properties (e.g. category).

The recommend command does not actually send the recommendation request to the Predict servers, for that, you have to issue the go command. After the Predict server received the requests, it computes the set of recommended products and sends it back to the browser. If you have specified a success handler in the recommend command, it will be invoked, so it will have a chance to modify the data objects corresponding to the recommended products. At the end, the success handler may or may not invoke the function responsible for rendering the recommended products. If you have not specified a success handler, the recommended products are rendered immediately according to the rendering template specified.

You can check whether recommendations are properly requested and rendered by using the Inspector.

In the template, you have access to the data objects describing the recommended products, in the form of JavaScript objects. These data objects contain the standard and custom properties specified in the product catalog) for the given product.

We suggest first familiarizing yourself with the recommender logics we offer, then start working on implementation.

See also