Retai Rocket tracking code consists of 6 small code snippets that need to be placed on your website.
Place this code on your site:
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>
Place this code on each product details page and quick view forms:
<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try{ rrApi.view(<product_id>); } catch(e) {}
})
</script>
Where <product_id> is a numeric ID of the product (must match the product ID in products XML feed).
Example:
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { try { rrApi.view(123); } catch(e) {} }) </script>
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>
Insert this code as an onMouseDown attribute in the code of all the buttons that add a product to a cart:
onmousedown="try { rrApi.addToBasket(<product_id>) } catch(e) {}"
Where, <product_id> is a numeric ID of the product (must match the product ID in products XML feed).
For example:
<div class="buy_button" onmousedown="try { rrApi.addToBasket(123) } catch(e) {}"></div>
Note: Add to cart buttons may be used not only on the product pages, but on the category pages or internal search results pages as well. Add to cart tracker must be installed there too.
Place this code on a "Thank you" page. This tracker should work with all payments and delivery methods, 1-click order forms.
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { try { rrApi.setEmail("<user_email>"); rrApi.order({ "transaction": "<transaction_id>", "items": [ { "id": <product_id>, "qnt": <quantity>, "price": <price>}, { "id": <product_id>, "qnt": <quantity>, "price": <price> } ] }); } catch(e) {} }) </script>
Where:
Example:
<script type="text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.setEmail($('#EmailFieldID').val());
rrApi.order({
"transaction": "1235421421",
"items": [
{ "id": 12312, "qnt": 4, "price": 130 },
{ "id": 64532, "qnt": 1, "price": 220 }
]
});
} catch(e) {}
})
</script>
Every time you have your visitor's email, run a code:
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { rrApi.setEmail("<user_email>"); });
Important: you can only use an email of a person, who clearly expressed his or her desire to receive email messages from your company, including email advertising campaigns.
Example 1: add the following attribute to the "Submit" button of sign-up forms that are used across your website:
onclick="try {rrApi.setEmail($('#EmailFieldID').val());}catch(e){}"
Example 2: add the following code to the "Thank you" page if a user subscribed to your newsletter during checkout process:
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { rrApi.setEmail("<user_email>"); }); </script>
Example 3: additional user data for email personalization:
<script type="text/javascript"> (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() { rrApi.setEmail("example@email.com", { "gender": "Male", "age": 21, "birthday": "15.01.1983" }); }); </script>
Recommended data to use:
More information about data transferring you can find here.