To set up Zinrelo's loyalty program on NetSuite, there are two basic integration points:

  1. Adding Zinrelo's Basic Javascript to all pages
  2. Setting up the code to track purchases

Basic Javascript

The basic Javascript is required to initialize the Zinrelo platform on the website and to authenticate customers in the loyalty program.
The javascript to be added is shown below. The Zinrelo partner ID will be available to you after your Zinrelo account has been created. If you use the standard web store, you should put this script in the template. If you use SiteBuilder and the Reference Checkout bundle, you can include the script in the common.html file which gets included on every page of the web store.  


<script type="text/javascript">
        window._zrl  =  window._zrl || [];
        var  init_data =
    'partner_id' : 'xxxxxxx',    
    'email' : "<%=getCurrentAttribute('customer','email')%>",
    'name' : "<%=getCurrentAttribute('customer','firstname')%>",
    'user_id': "<%=getCurrentAttribute('customer','internalid')%>"
        _zrl.push( [ 'init' , init_data ] );
<script src="//" type="text/javascript"></script>

Populate the following fields dynamically: ‘partner_id’, ‘email’, ‘name’, ‘user_id'. These fields contain end-user information – email, user full name and user_id – and must be filled dynamically wherever available. All the fields in this snippet are required.

If the user is not logged in to your website and these fields are not available, you need to pass an empty string. 

Below is a table with a detailed description of the fields to be populated dynamically. All fields are required and must be populated for the loyalty rewards program to work.

Purchase Tracking

Points are awarded for purchases when the purchase data is pushed from NetSuite to the Zinrelo program. There are two ways by which Zinrelo can receive information about the purchases.

  1. Purchase Tracking Javascript

Purchase Tracking Javascript

This script has to be added ONLY on the order confirmation / Thank You page of your site. It has to be added AFTER the basic integration snippet on the page.

  <script type="text/javascript">
        var products = [];

        /*Iterate over the purchase items and push them in the products array*/
        products.push ({
            'product_id' :'1234df', /* REQUIRED: Unique Product ID*/
            'price' :'69.75', /* REQUIRED: Product Price*/
            'quantity' : '1',  /* REQUIRED: Quantity Bought*/
            'title': 'Snoozeberry Travel Mug',  /* REQUIRED: Title of the product*/
   'url':'',/* OPTIONAL: URL of the product page*/
            'img_url':'', /* OPTIONAL: URL of the product image*/
   'category':'Mugs',/*OPTIONAL: Internal Product Category*/
   'tags':'Special, Coffee',/*OPTIONAL: Internal Product Tags*/
        /*End iteration*/

        var order_data =
            'order_id' : '2814151',/*REQUIRED: Internal Order ID */
            'total' : '99.25',/*REQUIRED: Total order value*/
            'subtotal' : '85.0',/*REQUIRED: Order value without shipping, taxes etc.*/
            'coupon_code' : 'NA',/*OPTIONAL: Coupon code used*/
            'currency': 'USD' , /*OPTIONAL: 3 letter currency code for your store.Defaults to USD*/
            'products' : products /*OPTIONAL- Array of products bought*/
        _zrl.push([ 'track_order' , order_data ] );

Detailed Explanation of the Purchase Tracking Javascript:
In the purchase tracking snippet, you must construct the order data and push the order data to Zinrelo. The picture below shows the flow of setting up the purchase tracking snippet.

Step 1. Populate the Product Array

Declare a JavaScript array that will host the product information. This array will then be included in the order array. Populate that array with information about each product included in that order. Note that each field in the product array is optional. Include whatever information is available about each product. The more fields you include in this array, the better you can define business rules based on the product information. This information is also displayed in detailed reports.


var products = [];
/*Iterate over the purchase items and push them in the products array*/
        products.push ({
            ‘product_id’ :‘1234df’, /*Unique Product ID*/
            ‘price’ :‘69.75’, /* Product Price*/
            ‘quantity’ : ‘1’,  /* Quantity Bought*/
            ‘title’: ‘Snoozeberry Travel Mug’,  
/*Title of the product*/
/*URL of the product page*/
/* URL of the product image*/
            'category':'Mugs, Gifts',
/*Comma-separated Prod Categories used for business rules*/
            'tags':'Special, Coffee',
/*Comma- separated Product Tags used for business rules*/
        /*End iteration*/

Here is a description of the various fields:

This step can be explained with an example. Let us assume that the order details are present in a javascript object named ‘order’ and it contains information about multiple products. The object order contains information about products bought in the attribute named items.

Iterate over the items and populate the products array with the product information as shown below:



This step of passing detailed product level information in the order is important because It gives you the ability to run product-specific businesses rules for the purchase activity. Here are use-cases that can be set up with product-specific business rules:

  • Award 3X number of points for products in Category=Mugs
  • Award 10X number of points for product ID = 1234df, because it is a high margin product
  • Award 100 bonus points for products in Category = Gifts

Zinrelo also uses this information to show detailed reporting in the Reports section of the Zinrelo Admin Console. Similarly, the user dashboard contains information about the products purchased.

Step 2. Populate Order Details

Declare an order_data object and populate that with the order details. Include the product data array in the order_data object. Please use the order parameter keys exactly as given in the script below. Push the order_data object to Zinrelo.


var order_data =
             ‘order_id’ : ‘2814151’,/*REQUIRED: Internal Order ID */
             ‘total’ : ‘99.25’,/*REQUIRED: Total order value*/
             ‘subtotal’ : ‘85.00’,
/*REQUIRED: Order value without shipping, taxes etc.*/
             ‘coupon_code’ : ‘FREE50’,/*RECOMMENDED: Coupon code used*/
             ‘currency’: ‘USD’ ,
/*RECOMMENDED: 3 letter currency code*/
             ‘products’ : products
/*RECOMMENDED: Array of products bought*/
    }_zrl.push([ ‘track_order’ , order_data ] );

Here is a description of the various fields:


With the Javascript approach for purchase tracking, points will be awarded when the thank you page loads. If you wish to award points after the order is paid or shipped you can use Zinrelo's REST API to push the purchase data to Zinrelo.

Link to Zinrelo's API documentation:
To track purchases, use the Purchase API endpoint (POST

To use the API, you can first set up a NetSuite scheduled script to fetch all purchase transactions recorded in NetSuite. And then through the script, you can call Zinrelo's Purchase API to award points for all those transactions.

Live NetSuite Implementations

  1. Wrigleyville Sports

2. Maharishi Ayurveda

Did this answer your question?