Skip to main content

Product API Code Example

Description

If the online store does not contain grouped products, call retailrocket.products.post({}) in the product card and pass all product information. If support for grouped products is required, use retailrocket.productsGroup.post({}).

Important: if there is a "quick view" of a product, the tracking code must also be called when this window is opened.

Code Example

<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
retailrocket.products.post({
"id": <product ID>,
"name": "Example product name",
"price": 777,
"pictureUrl": "http://example.com/path/to/Photo.jpg",
"url": "http://www.example.com/path/to/productPage",
"isAvailable": true,
"categoryPaths": ["Women/Clothes/Skirts","Women/New Arrivals"],
"description": "Some text description",
"vendor": "Brand name",
"model": "Model name",
"typePrefix": "Product type",
"oldPrice": 999,
"params": {
"<custom parameter 1 name>": "<custom parameter 1 value>",
"<custom parameter 2 name>": "<custom parameter 2 value>",
"<custom parameter N name>": "<custom parameter N value>"
}
});
rrApi.view(<product ID>);
});
</script>

Required Product API Parameters without Grouped Products

ParameterTypeDescription
idintegerUnique product identifier, numbers only, up to 16 characters. Must not exceed 9,007,199,254,740,991.
namestringProduct name, up to 120 characters. It is better to specify the full unique name.
pricenumericalPrice per unit, can be integer or fractional, not equal to zero.
urlstringAbsolute link to the product page, up to 512 characters.
pictureUrlstringAbsolute link to the product image (jpeg/gif/png). Recommendation: ≤ 400×400 or ≤ 1 MB. Up to 512 characters.
isAvailableboolAvailability status: true product is in stock, false not. Value is case-sensitive, use lowercase.
categoryPathsstringArray of paths to low-level categories, separated by /. Paths must match the menu structure. For multiple categories, pass an array, for example ["Women/Clothes/Skirts","Women/New Arrivals"].
descriptionstringShort description. For HTML, wrap in CDATA. No more than 200 characters.

Required Product API Parameters with Grouped Products

ParameterTypeDescription
productsJSON objectContains all products of the group, each as a separate object. isAvailable is mandatory. Other fields, if absent, are taken from the general group parameters.
groupIdinteger/stringIdentifier for a group of variations of a single model. For non-grouped items, the offer identifier can be passed.

Additional Parameters

ParameterTypeDescription
vendorstringManufacturer or brand. Used in manufacturer-based recommendations.
oldPricenumberOld price. Can be shown in recommendations or used to calculate discounts.
paramsJSON objectProduct characteristics. Up to 40 elements "<param name>": "<value>". Values can be used for filtering and displayed in widgets.

Parameter for Regionality Support

ParameterTypeDescription
stockIdstringUser's region/warehouse/language identifier. Each region should have at least 5 times more unique visitors per month than the number of products in the region.

Multi-language and Multi-currency Support

If the website allows users to choose from several languages and currencies, then additional parameters can be used to implement the same functionality in Retail Rocket products.

<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
retailrocket.products.post({
"id": <product ID>,
"name": "Example product name",
"price": 777,
"pictureUrl": "http://example.com/path/to/Photo.jpg",
"url": "http://www.example.com/path/to/productPage",
"isAvailable": true,
"categoryPaths": ["Women/Clothes/Skirts","Women/New Arrivals"],
"description": "Some text description",
"vendor": "Brand name",
"model": "Model name",
"typePrefix": "Product type",
"oldPrice": 999,
"params": {
"<custom parameter 1 name>": "<custom parameter 1 value>",
"<custom parameter 2 name>": "<custom parameter 2 value>",
"<custom parameter N name>": "<custom parameter N value>",
"languages": {
"<language1>": {
"description": "description in language1",
"name": "name in language1",
"url": "url to product in specific language",
"<custom parameter 1 name in language1>": "<custom parameter 1 value>",
"<custom parameter 2 name in language1>": "<custom parameter 2 value>",
"<custom parameter N name in language1>": "<custom parameter N value>"
},
"<language2>": {
"description": "description in language2",
"name": "name in language2",
"url": "url to product in specific language",
"<custom parameter 1 name in language2>": "<custom parameter 1 value>",
"<custom parameter 2 name in language2>": "<custom parameter 2 value>",
"<custom parameter N name in language2>": "<custom parameter N value>"
}
},
"currencies": {
"EUR": <price in EUR>,
"USD": <price in USD>
}
}

});
});
</script>