The method returns an API response when requesting product recommendations.
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.
Unique code of the recommendation block. See this value in the "data-recommender-code" attribute of the block created in PersonaClick account.
params
object
required
Object with request parameters.
success
function
required
A callback function, to which the API response will be passed. Response type: object.
error
function
optionally
A callback function that will be called when an error occurs (any HTTP status code other than 200).
Request parameters
Name
Type
Requirement
Description
item
number/string
required in some cases
Product ID. This parameter is mandatory for the requests of blocks that use the algorithms "Similar" and "Also bought".
exclude
array
optionally
Product IDs array, which should be excluded from the recommended products list.
category
number/string
required in some cases
Category ID. This parameter is mandatory for all blocks set on category pages.
search_query
string
required in some cases
The text of the search query. This parameter is mandatory for the requests of blocks that use the "Search" algorithm.
limit
number
optionally
A maximum number of products per page.
locations
array
optionally
Array with location IDs. If used, the API response will return products available in the listed locations.
brands
array
optionally
Array with brand names. If used, only the products of the listed brands will be returned in the API response.
exclude_brands
array
optionally
Array with brand names. If used, the API response will exclude the products of the listed brands.
categories
array
optionally
Array with category IDs. If used, the API response will only return products that are included in the listed categories.
discount
boolean
optionally
If 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.
page
number
optionally
Page number (first page - 1, by default - 1).
prevent_shuffle
boolean
optionally
If "true" it disables product shuffling to use the "page" parameter so that each page contains unique products.
API response properties
Name
Type
Description
html
string
HTML-code of the block with products. The template is customized in the PersonaClick account.
title
string
The block title. Corresponds to the value of the "Action" element in the block rules.
products
array
Array with product IDs.
id
number
Unique block identifier. Corresponds to the block ID in the list of blocks in the PersonaClick account.
snippet
string
JS snippet code attached to the recommender.
Examples of use
For blocks with algorithms that require the "Product ID":
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {item: 100500}, function(response) {
// the functionality of rendering a block of product recommendations
}, function(error) {
// when something went wrong
});
For blocks with algorithms that require the "Category ID":
personaclick("recommend", "1fd1b3495137bc3c9299816026acf36f", {category: 146}, function(response) {
// the functionality of rendering a block of product recommendations
}, function(error) {
// when something went wrong
});
For blocks with an algorithm that requires the "Search Query":
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
});
Full example:
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
});