Transaction tracking code

Description

Place this code on a "Thank you" page. Tracking code must be executed for every payment/delivery method and for quick order forms.

📘

Tracking code for collecting a customer' data

It's necessary to execute email tracking code with transaction tracking code in the same time.

In case if a making purchase requires to register or login - you need to use rrApi.setCustomer tracking code. If there is no need for a customer to make registration - it should be rrApi.setProfile tracking code.

🚧

transaction_id- is an ID of the transaction (string);

email_address - email_address - is a user's email address, which he left at checkout;

isAgreedToReceiveMarketingMail - subscription consent, boolean type, optional; default value is true;

product_id - is a numeric product ID, must correspond to ID which is passed in product database;

qnt - is a quantity of products bought;

price - is a price per one product;

Example of a code if registration is required

<script type = "text/javascript">
    (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
        try {
            rrApi.setCustomer({
                customerId: <customerId>,
                email: <email_address>,
              	isAgreedToReceiveMarketingMail: <true/false>
            });
            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>,
                isAgreedToReceiveMarketingMail: <true/false>
            });
            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>

Example of a code if registration is not required

<script type = "text/javascript">
    (window["rrApiOnReady"] = window["rrApiOnReady"] || []).push(function() {
        try {
            rrApi.setProfile({
                email: <email_address>,
                isAgreedToReceiveMarketingMail: <true/false>            

            });
            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>,
                isAgreedToReceiveMarketingMail: <true/false> 
            });
            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 is Product Id String parameter must additionally be passed to the tracking code. The example is given 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>