Introduction

Zinrelo loyalty rewards program can be integrated on your website by setting up the basic integration and authentication Javascript and then setting up the purchase tracking API.

In this document, we will walk you through the basic integration snippet in detail. The target audience for the document is the technical developer responsible for making code changes to your website.

Here is a video to guide you through integrating the Basic Integration Snippet:

If you are looking for an overview of integrating Zinrelo on your website, please see this document 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.

The basic integration snippet is used to enable the Zinrelo resources on your website. It captures basic details of users like email id, user name and user ID. This information is used to successfully login a user in Zinrelo’s reward program.

Where to find the snippet?

A customized basic integration code snippet for your account is available in your Zinrelo Admin Console in the ‘General’ tab under ‘Integration’.

How to include the snippet?

Add the snippet into the HEAD section of your website page template so that this snippet appears on ALL pages of your website. The JavaScript snippet looks like this:

Js


       window._zrl  =  window._zrl || [];
       var  init_data =
       {
         ‘partner_id’ : XXXXXXXX, /*REQUIRED: Zinrelo Partner ID*/
         ‘email’ : ‘useremail@gmail.com’,
         /*REQUIRED: When User is Logged in. For Non-Logged in users,
         pass an empty string ('').*/
         ‘name’ : ‘User  Full Name’,        
         /*REQUIRED: When User is Logged in. For Non-Logged in
         users, pass an empty string (''). */
          ‘user_id: ‘Unique-user-ID’
          /*REQUIRED: When User is Logged in. For Non-Logged in users and  
          guest users who DO NOT have an account, pass an empty string ('')*/
       };
       _zrl.push( [ ‘init’ , init_data ] );

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. If only the user_id field is not available to Zinrelo on a particular page, it is still assumed that the customer is not logged in to the website and will be logged out of the loyalty program too.

Shown 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.

Common Mistakes

Here are some common mistakes in including the Basic Integration Snippet:

  • Partner ID is copied as-is from this document: The partner_id field is a unique key generated by Zinrelo to identify a Client. Please confirm that your partner_id is correct. If you are copying code from the Zinrelo Admin Console, the partner_id will be correct. If you are copying as-is from this document, the partner_id will be wrong.
  • Integration snippet is copied as-is: The fields must be filled dynamically from the information available on the website. Therefore, a developer with some technical skills is required to complete this task. It is not a mere copy and paste.
  • All.js code is not copied onto the website: Zinrelo uses a Javascript called all.js. This script must be included in snippet.

    <script src = “//cdn.zinrelo.com/js/all.js” type=“text/javascript”>

    However, please do not look at the insides of all.js and copy that code to your website. Some variables will not be available and the script will fail.
  • Incomplete information is passed: For example, user_id field is passed but email and full name are not passed. This causes the email engine which engages the user to fail. If all the information is not available, the program will not work.

Once you have added the basic snippet on your website, next step is to set up the purchase tracking API. 

Did this answer your question?