Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Method Objective

The method returns an API response when requesting product recommendations.

Note

Please note that the priority way of placing the product recommendations blocks on the site is to insert the DIV tag created in the PersonaClick account and fill it automatically with the PersonaClick library. The instruction below is intended for exceptional cases when an automatic drawing of the block doesn't give the maximum necessary functionality.

Syntax and parameters

Code Block
themeFadeToGrey
personaclick("recommend", code, params, success, error);

Request

EndpointRequest Type
https://api.personaclick.com/recommend/{% recommender_code %}GET

Parameters

Name

TypeRequirement

Description

recommender_codestringrequiredUnique code of the recommendation block. See this value in the "data-recommender-code" attribute of the block created in PersonaClick account.
paramsobjectrequiredObject with request parameters.successfunctionrequiredA callback function, to which the API response will be passed. Response type: object.errorfunctionoptionallyA callback function that will be called when an error occurs (any HTTP status code other than 200).

Request parameters

NameTypeRequirementDescription
 The parameter builds the endpoint for the recommendation request.
shop_idstringrequiredUnique Store Key in PersonaClick. Located there: Account > Settings > Store Settings
didstringrequiredUnique Device ID. See "Initialization (REST API)" for information about getting and using Device ID.
seancestringrequiredUnique ID of the current user session. See "Initialization (REST API)" for information about getting and using User Session ID.
segmentstringoptionallyCan take one of the values: "A" or "B" according to the segment to which the user is assigned. You can use your algorithm to divide users evenly between the segments.
itemnumber/stringrequired in some casesProduct ID. This parameter is mandatory for the requests of blocks that use the algorithms "Similar" and "Also bought".
exclude
array
stringoptionallyProduct IDs
array
(splitted by comma), which should be excluded from the recommended products list.
categorynumber/stringrequired in some casesCategory ID. This parameter is mandatory for all blocks set on category pages.
search_querystringrequired in some casesThe text of the search query. This parameter is mandatory for the requests of blocks that use the "Search" algorithm.
limitnumberoptionallyA maximum number of products in the API response.
locations
array
stringoptionally
Array with location IDs
Location IDs, splitted by comma. If used, the API response will return products available in the listed locations.
brands
array
stringoptionally
Array with brand names
Brand names, splitted by comma. If used, only the products of the listed brands will be returned in the API response.
exclude_brands
array
stringoptionally
Array with brand names
Brand names, splitted by comma. If used, the API response will exclude the products of the listed brands.
categories
array
stringoptionally
Array with category IDs
Category IDs, splitted by comma. If used, the API response will only return products that are included in the listed categories.
discountbooleanoptionallyIf used with "true" value, then only those products, the value of which is less than the "oldprice" value, will be returned in the API response.
resize_imagenumberoptionallyProduct Image Size. Available values (px): 120, 140, 160, 180, 200, 220. The default is the original size.
extendednumberoptionallyIf it's set to 1 value, the API will return extended product information in the recommends property. Otherwise, only product IDs will be returned.
prevent_shufflebooleanoptionallyIf set to true value this will disable product shuffling in the API response.
pagenumberoptionallyUsed when pagination is needed. The API returns products of the specified page and limit (limit is set in the block's settings in the account or as an additional parameter in the request).

API Response Code

HTTP status code

Description
200 OK

The request was successful.

404 Not FoundThere are no mandatory parameters in the query.

API Response Data

The API returns an array of category objects. Below are the properties of a single object.

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.
products
recommendsarray
Array with product IDs
/Object arrayThis property will contain an array of products by default, or an object array with extended product information if the extended parameter is used in the API request.
idnumberUnique block identifier. Corresponds to the block ID in the list of blocks in the PersonaClick account.
snippetstringJS snippet code attached to the recommender.

Request Examples

of use

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

Code Block
languagejs
themeFadeToGrey
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {item: 100500}, function(response) {
  // the functionality of rendering a block of product recommendations
}, function(error) {
  // when something went wrong
});curl 'https://api.personaclick.com/recommend/1fd1b3495137bc3c9299816026acf36f?shop_id=0d42fd8b713d0752776ca589cc0056&did=iVxRcAaGzA&seance=C6vpfZPlpz&segment=A&item_id=100500'


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

Code Block
languagejs
themeFadeToGrey
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {category: 146}, function(response) {
  // the functionality of rendering a block of product recommendations
}, function(error) {
  // when something went wrong
});curl 'https://api.personaclick.com/recommend/1fd1b3495137bc3c9299816026acf36f?shop_id=0d42fd8b713d0752776ca589cc0056&did=iVxRcAaGzA&seance=C6vpfZPlpz&segment=A&category=146'


For blocks with an algorithm that requires the "Search Query":

Code Block
languagejs
themeFadeToGrey
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {search_query: "To be or not to be"}, function(response) {
  // the functionality of rendering a block of product recommendations
}, function(error) {
  // when something went wrong
});curl 'https://api.personaclick.com/recommend/1fd1b3495137bc3c9299816026acf36f?shop_id=0d42fd8b713d0752776ca589cc0056&did=iVxRcAaGzA&seance=C6vpfZPlpz&segment=A&search_query=To%20be%20or%20not%20to%20be'


Full example:

Code Block
languagejs
themeFadeToGrey
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {item: 100500, exclude: [3, 14, 159, 26535], category: 146, search_query: "To be or not to be", limit: 15, brands: ["Alas", "poor", "Yorick"], categories: [1, 146, 100500]}, function(response) {
  // the functionality of rendering a block of product recommendations
}, function(error) {
  // when something went wrong
});curl 'https://api.personaclick.com/recommend/1fd1b3495137bc3c9299816026acf36f?shop_id=0d42fd8b713d0752776ca589cc0056&did=iVxRcAaGzA&seance=C6vpfZPlpz&segment=A&search_query=To%20be%20or%20not%20to%20be&category=146&categories=1%2C146%2C100500&exclude=3%2C14%2C159%2C26535&item_id=60496856&limit=15&brands=Alas%2Cpoor%2CYorick'


Table of Contents
classpersonaclick-fixed-position