Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Method Objective

The method returns an API response when requesting product recommendations.

Syntax and parameters

sdk.recommend(params) { callback }
NameTypeRequirementDescription
paramsenumrequiredRequest parameters.
callbackfunctionrequiredA callback function, to which the API response will be passed.

Request parameters

NameTypeRequirementDescription
blockIdstringrequiredUnique code of the recommendation block. See this value in the "data-recommender-code" attribute of the block created in PersonaClick account.
currentProductIdstringrequired in some casesProduct ID. This parameter is mandatory for the requests of blocks that use the algorithms "Similar" and "Also bought".

API response properties

NameTypeDescription
htmlstringHTML-code of the block with products. The template is customized in the PersonaClick account.
titlestringThe block title. Corresponds to the value of the "Action" element in the block rules.
recommendsarray/ObjectArray with product IDs. If an extended response is requested, this property will have an object array with extended information for each product.
idnumberUnique block identifier. Corresponds to the block ID in the list of blocks in the PersonaClick account.

Examples of use

For blocks with algorithms without any additional parameters:

sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f") { recommendResult in
  // the functionality of rendering a block of product recommendations
}

For blocks with algorithms that require the "Product ID":

sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f", currentProductId: "100500") { recommendResult in
  // the functionality of rendering a block of product recommendations
}

  • No labels