1. Main tracking code
Place this piece of code on each page of your website in the <head> section:
<script type="text/javascript">
var rrPartnerId = "partnerIdFromPartnerOffice";
var rrApi = {};
var rrApiOnReady = rrApiOnReady || [];
rrApi.addToBasket = rrApi.order = rrApi.categoryView = rrApi.view =
rrApi.recomMouseDown = rrApi.recomAddToCart = function() {};
(function(d) {
var ref = d.getElementsByTagName('script')[0];
var apiJs, apiJsId = 'rrApi-jssdk';
if (d.getElementById(apiJsId)) return;
apiJs = d.createElement('script');
apiJs.id = apiJsId;
apiJs.async = true;
apiJs.src = "//mcdn.retailrocket.net/content/javascript/trackingm.js";
ref.parentNode.insertBefore(apiJs, ref);
}(document));
</script>
2. Product page tracker
Place this code on each product details page and quick view forms:
<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
// Send products data
retailrocket.productsGroup.post({
// Group ID, number without quotes
// If a product is not merged by group, use Product ID as Group ID
"groupId": <group ID>,
// Product’s name
"name": "<string>",
// Product’s price
"price": <decimal>,
// Product’s picture URL, maximum 1 MB. Preferred image width 400-400 px. Pictures format JPEG or PNG.
// We recommend using images from category page. These images will be used in recommendation blocks and emails.
"pictureUrl": "<string>",
// Product’s URL
"url": "<string>",
"isAvailable": <bool>,
// Array of product category name paths with a slash as category level separator.
// Category path must exactly reflect your website menu structure and categories nesting
// (please use static category names only, no URL paths, sidebar filters or dynamic
// breadcrumbs are allowed). Specify only lowest level (if the product is listed
// in categories "Women/Clothes/Skirts" and "Women/Clothes/" you should only pass
// "Women/Clothes/Skirts")
"categoryPaths": ["Example/Category/Path","Another/Category"],
// Product’s description, optional parameter
"description": "<string>",
// Product Vendor (e.g. HP)
"vendor": "Brand name",
// Products in group specifications
"products": {
"<product id>": {
"isAvailable": <bool>,
// Product’s name, optional parameter
"name": "<string>",
// Product’s color, optional parameter
"color": "<string>",
// Product’s size, optional parameter
"size": "<string>",
// Product’s URL, optional parameter
"url": "<string>",
// Product’s picture URL, maximum 1 MB. Preferred image width 400-400 px. Pictures format JPEG or PNG.
// We recommend using images from category page. These images will be used in recommendation blocks and emails.
"pictureUrl": "<string>",
// Product’s price, optional parameter
"price": <decimal>,
// Product’s old price, optional parameter
"oldPrice": <decimal>,
// Product’s description, optional parameter
"description": "<string>",
// Product additional information, optional parameter
"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>"
}
},
"<product id>": {
"isAvailable": <bool>,
"name": "<string>",
"color": "<string>",
"size": "<string>",
"url": "<string>",
"pictureUrl": "<string>",
"price": <decimal>,
"oldPrice": <decimal>,
"description": "<string>",
"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>"
}
}
},
// Product model (e.g. LaserJet 3500), optional parameter
"model": "Model name",
// Product type (e.g. Laser Printer), optional parameter
"typePrefix": "Product type",
// Old price, used to indicate products on sale, optional parameter
"oldPrice": 17.46
});
// Group’s product IDs, array of numbers
rrApi.groupView([<product IDs>]);
});
</script>Field params contains custom fields which will be available on the website recommendation display or in emails.
3. Category page tracker
Place this code on each category page:
<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
// Full path to current category with slash as a separator, string. It must match the path transmitted in product pages in this category.
rrApi.categoryView("Women/Clothes/Skirts");
});
</script>