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.

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

Google Customer Reviews

Google Customer Reviews is a free program that allows Google to collect seller reviews on your behalf from your customers. Read more at Introducing Google Customer Reviews page.

Code below was taken from Add the opt-in code and slightly modified to work at checkout success page. Check source link to get more info about code below.

<!-- BEGIN GCR Opt-in Module Code -->
<script src=""
  async defer>

  window.renderOptIn = function() {
    window.gapi.load('surveyoptin', function() {
      var shippingData = {{orderShippingAddress}},
          today = new Date(),
          estimatedDate = new Date();

      estimatedDate.setDate(today.getDate() + 3); // estimated delivery date is 3 days from now
          // REQUIRED
          "order_id": "{{orderId}}", // ORDER_ID
          "email": "{{customerEmail}}", // CUSTOMER_EMAIL
          "delivery_country": shippingData.country_id,
          "estimated_delivery_date": estimatedDate.toISOString().slice(0, 10),

          // OPTIONAL
          "opt_in_style": "OPT_IN_STYLE"
<!-- END GCR Opt-in Module Code -->

Customer type (guest or registered customer)

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

Ordered Items SKUs

Requires Checkout Success Page version 1.1.3 or higher.

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

Quantity of ordered products

Requires Checkout Success Page version 1.1.3 or higher.

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

Estimated delivery date

It’s just an example how you can calculate estimated delivary date.

In this case we know that shipping method with code FAST_DELIVERY deliver products within 1 day, THREE_DAYS_DELIVERY - deliver within 3 days and all other methods deliver within 4 days.

<script type="text/javascript">
    var today = new Date(),
        estimatedDate = new Date(),
        shippingMethod = '{{shippingCode}}';
    if (shippingMethod == 'FAST_DELIVERY') {
        estimatedDate.setDate(today.getDate() + 1);
    } else if (shippingMethod == 'THREE_DAYS_DELIVERY') {
        estimatedDate.setDate(today.getDate() + 3);
    } else {
        // all other methods delivers within 4 days
        estimatedDate.setDate(today.getDate() + 4);
    // now estimatedDate containes delivery date depending
    // on shipping method customer used in order
Edit this Page