SwissUpLabs Logo

Miscellaneous scripts snippets

Here you can find some code snippets that can be used in Miscellaneous scripts of Checkout Success Page extension.

Google AdWords conversion tracking tag

It is just an example. send_to property has to have your own value.

<script>
    gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC-D_efG-h12_34-567',
        'value': {{orderAmount}},
        'currency': '{{currency}}'
    });
</script>

Customer type (guest or registered customer)

<script type="text/javascript">
    var customerType = '{{customerId}}' ? 'registered' : 'guest';
</script>

Ordered Items SKUs

Requires Checkout Success Page version 1.1.3 or higher.

<script type="text/javascript">
    var orderedItems = {{orderItems}};
    var orderedSKUs = jQuery.map(orderedItems, function(v){ return v.sku; }); // Array
</script>

Quantity of ordered products

Requires Checkout Success Page version 1.1.3 or higher.

<script type="text/javascript">
    var orderedItems = {{orderItems}};
    var orderedQty = 0;
    jQuery.map(orderedItems, function(v){ orderedQty += parseFloat(v.qty_ordered); });
    // now orderedQty containes quantity of ordered products
</script>
Edit this Page