Transaction tracking code
Description
On the final checkout page ("Thank you for your order"), you must install and call this transaction tracking code. The tracking code must be triggered for all available payment and delivery methods.
It should also be called when submitting an order through the "Quick Order" and "Buy in 1 Click" forms.
You must call the user data collection tracking code at the same time as the transaction tracking code.
If the user must be authorized/registered to make a purchase, you need to use the rrApi.setCustomer tracking code. If authorization/registration is not required, you need to use the rrApi.setProfile tracking code.
transaction_id - transaction identifier, i.e. order number. It is advisable to pass the same identifiers to the tracking code that are used in the store's CMS;
email_address - the user's email address that he left at checkout;
product_id - ID of the product that the user has purchased. Must match the product ID passed in the product database;
qnt - the number of units of the product in the order, cannot be equal to zero or less than zero;
price - the price per unit of the product, cannot be less than zero;
Code example if authorization/registration is required
- Without regionality
- With regionality
<script type = "text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.setCustomer({
customerId: <customerId>,
email: <email_address>
});
rrApi.order({
"transaction": "<transaction_id>",
"items": [{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
},
{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
}
]
});
} catch (e) {}
})
</script>
<script type = "text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.setCustomer({
customerId: <customerId>,
email: <email_address>,
defaultStockId: <stockId>
});
rrApi.order({
"transaction": "<transaction_id>",
"items": [{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
},
{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
}
],
"stockId": "<stock_id>"
});
} catch (e) {}
})
</script>
Code example if authorization/registration is not required
- Without regionality
- With regionality
<script type = "text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.setProfile({
email: <email_address>
});
rrApi.order({
"transaction": "<transaction_id>",
"items": [{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
},
{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
}
]
});
} catch (e) {}
})
</script>
<script type = "text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.setProfile({
email: <email_address>,
defaultStockId: <stockId>
});
rrApi.order({
"transaction": "<transaction_id>",
"items": [{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
},
{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
}
],
"stockId": "<stock_id>"
});
} catch (e) {}
})
</script>
Support for string identifiers
If the product identifiers in the product database have string identifiers, an object with the isProductIdString parameter must also be passed to the tracking code, an example is shown below
<script type = "text/javascript">
(window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
try {
rrApi.order({
"transaction": "<transaction_id>",
"items": [{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
},
{
"id": <product_id> ,
"qnt": <quantity> ,
"price": <price>
}
].
"isProductIdString": true
});
} catch (e) {}
})
</script>