Tracking code for adding product to the basket

Description

In this tracking code, you need to pass the product ID, which corresponds to the product ID passed in the product database. It should be installed on all buttons, which lead to adding the product to the cart. (On the product card page / in the category listing / on the quick view window)

It should also be called when the user clicks on the "Buy in 1 click" or "Quick order" button, even if this button does not add product to the website' cart.

Clicking on these buttons is the closest action to making an order, so it is important to track this user behaviour.

πŸ“˜

Multiregionality

If the integration requires the using of regions (stocks), then the ID of the region in which the user is located must additionally be passed to the tracking code.

All code examples are shown on two tabs - with and without regionality support.

🚧

Region ID (stock ID)

<stock_id> - Identifier of the stock to which products belong, string. Must match identifier of stock, which is passed in the product database.

Example of a code for integration without stocks

<script type="text/javascript">
    (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
        try { rrApi.addToBasket(<product_id>); } catch(e) {}
    })
</script>

Example of a code for integration with stocks

<script type="text/javascript">
    (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
        try { rrApi.addToBasket(<product_id>,{'stockId': '<stock_id>'}); } catch(e) {}
    })
</script>