- Basic Integration & Authentication Snippet
- Purchase Tracking Snippet
If you haven’t seen the basic integration document yet, please go through that before reading about purchase tracking. In this document, we will walk you through the purchase tracking snippet in detail. A basic understanding of Java scripts is necessary to follow this document.
If you are looking for an overview of integrating Zinrelo on your website, please start with - Getting Started with Zinrelo Integration. If you are using one of the pre-integrated shopping carts like Magento or Shopify, you do not have to do this step separately.
As the name implies, the purchase tracking snippet captures details of the purchase including the customer data, order data and product data. This information is used to track referrals, award loyalty points, create business rules for activities and show detailed program reports.
This script has to be added ONLY to the order confirmation / Thank You page of your site. It has to be added AFTER the basic integration snippet on the page.
Where to find the snippet?
A customized purchase tracking snippet for your account is available in your Zinrelo Admin Console in the ‘General’ tab under ‘Integration’.
How to include the snippet?
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
var products = ;
/*Iterate over the purchase items and push them in the products array*/
‘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*/
/*Comma-separated Prod Categories used for business rules*/
/*Comma- separated Product Tags used for business rules*/
Here is a description of the various fields:
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 products 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:
Common Mistakes to Avoid
Here are some common mistakes in including the Product Tracking Snippet:
- Integration snippet is copied as-is. The following fields must be filled dynamically from the information available on the website: ‘product_id’, ‘price’, ‘quantity’, ‘title’, ‘url’, ‘img_url’, 'category', 'tags', ‘order_id’, ‘total’, ‘subtotal’, ‘coupon_code’, ‘currency’. Therefore, a developer with some technical skills is required to complete this task. It is not a mere cut and paste.
- Incomplete order information is passed. For example, order_id field is passed but total and subtotal are not passed. This causes the points award engine to fail.
- The array “products” is not populated. The array that contains product details is optional. But if you do not include it, it severely limits your ability to define product-specific business rules that can help you implement a sophistication loyalty rewards program.
- The array “products” is defined AFTER the order_data object. The products array must be defined BEFORE the order_data object. Otherwise, it cannot be referenced in the order_data object.
- Product Tracking snippet is included on all website pages. Include this snippet only on the Order Confirmation page after the user has finished placing the order. The product and order information is available only on that page.
- Product Tracking Snippet is included BEFORE the Basic Integration Snippet. Typically, the Basic Integration Snippet is included in the HEAD section of the website. Hence, this problem should not occur. But in no circumstances should the Product Tracking Snippet be included before the Basic Integration snippet. It will result in an error.
- Data Values are not passed within Quotes. All data values must be passed as a string. Within quotes ‘ ‘.
- Custom Product and Order Parameter Names are used. Zinrelo will not recognize Product and Order parameter names unless they are used exactly as mentioned in the script above.
After you have set up the Purchase tracking snippet, you can move on to testing the integration snippets.