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 = "//cdn.retailrocket.net/content/javascript/tracking.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() {
try{ rrApi.groupView([<product_ids>],{"stockId": "<stock_id>"}); } catch(e) {}
})
</script>Where:
- <product_ids> - group's product IDs, array of numbers (must match the product ID in products XML feed),
- <stock_id> is a region ID (string).
Example:
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { try { rrApi.groupView([123,456], {"stockId": "10"}); } catch(e) {} }) </script>
3. Category page tracker
Place this code on each category page:
<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try { rrApi.categoryView(<category_id>); } catch(e) {}
})
</script>
Where <category_id> is a numeric ID of the category (must match the category ID in products XML feed).
Example:
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { try { rrApi.categoryView(123); } catch(e) {} }) </script>