search

Offer Discovery Widget

Overview

An offer discovery widget is a tool that can significantly enhance user engagement and conversion rates on your website or app by increasing the discovery of offers/subvention. 

Advantages of Offer Discovery Widget

  • Increased Engagement: Offer discovery widgets grab user attention with timely and relevant offers, increasing the time spent on your platform.
  • Higher Conversion Rates: Displaying options that can make purchases affordable can lead to higher conversion rates as users are more likely to act on deals that are relevant to them.
  • Boosted Sales and Revenue: Encouraging users to take advantage of promotions can directly boost sales and increase average order values.
  • Ease of integration: Can be easily integrated with minimal one-time effort.

 

Why Paytm's Offer discovery widget?

  • Offer widget can be quickly integrated with minimal lines of code snippet 
  • Can show different offers and EMI plans applicable
  • Offers running on different payment options like CC, DC and EMI can be shown on the widget. Other payment options shall also be supported in the subsequent releases
  • Any new offers will reflect in less than 30 mins after going live
  • Any expired or deactivated offers will stop being shown without any additional deployment

Paytm's offer discovery widget can be integrated on:

Product Description Pages(PDP)

Cart Page

Checkout Page

✅

✅

✅

User Journey

  • Merchant integrates the widget on their PDP page. When user lands on PDP page, on load of the widget, the below section would be visible to the user on the webpage.
  • User clicks on “View all offers” and then the popup opens taking the user to No Cost EMI section.
  • User then can navigate to the Pay in full section to discover the offers on instruments like Credit Card, Debit Card etc.

Demo

Prerequisites

Before you begin the integration, make sure you follow the steps below:

  • Register as a merchant with Paytm. You will be provided with a Merchant Identifier - MID and key which can be used for accessing all the APIs provided by Paytm.
  • Create and activate offers following the process here
  • For EMI, please get the payment instrument enabled on your MID
  • Please refer to our Affordability Suite for further information on all our offerings related to bank offers and EMI which can be used to make the purchases affordable for the user.
  • Please integrate the Access Token API which would be used in the widget script.

Integration Steps

  • On your website, on the page where you would like to integrate the widget, create an empty element where you want to inject the offer banner, such as a “<span>” element with the ID "banner". 
  • Copy and paste the following snippet into your code. Then, add the required details to the configuration object:
<div id="banner-container" class="paytm-banner-wrap">
<span id="banner"></span>
</div>

<script>
  function onScriptLoad(){
      var config =  {
                "root": "#banner",
                "data": {
                  "accessToken": "ACCESS_TOKEN_HERE",
                  "referenceId": "ACCESS_TOKEN_REFERENCE_ID",
                  "amount": "10000",    // total cart value
                  "offerDiscoveryInfo": {
                    "amountBasedBankOffer": false,   // mandatory to determine type of Bank offer
                    "items": [
                      {
                        "id": "item1116",             //random identifier for item 
                        "productId": "2",             // SKU code configured in the merchant's DB
                        "brandId": "1707",            // Brand identifier assigned for the brand
                        "categoryId": "124",          // Category identifier assigned for the category
                        "model": "iphone_11_24",      // Model configured in the merchant's DB
                        "price": 10000.00             // price of the product
                      }
                    ],
                    "amountBasedSubvention": false    // mandatory to determine type of subvention
                  },
                  "userDetail": 
                              {
                         "mobileNumber": "1111111111"  
                    }
                },
                "merchant": {     "mid": "YOUR_MID_HERE" }
};
    if(window.Paytm && window.Paytm.OfferJS){
        window.Paytm.OfferJS.onLoad(function excecuteAfterCompleteLoad() {
            window.Paytm.OfferJS.initLib(config.merchant.mid).then(res => {
                 window.Paytm.OfferJS.init(config).then(res => {
                     window.Paytm.OfferJS.invoke();
                 })
             })
        })
      }
  }
</script>

<script type="application/javascript" crossorigin="anonymous" src="{HOST}/merchantpgpui/offerjs/merchants/{MID}.js" onload="onScriptLoad();"> </script>

 

<script>
    function onScriptLoad(price) {
        // Remove the existing script if it exists
        let oldScript = document.getElementById('dynamicScript');
        if (oldScript) {
            oldScript.parentNode.removeChild(oldScript);
        }

        // Remove the existing banner if it exists
        let selector = document.getElementById('banner');
        if (selector) {
            selector.remove();
        }

        // Create a new div for the banner
        let div = document.createElement("div");
        div.setAttribute("id", "banner");
        let bannerContainer = document.getElementById("banner-container");
        bannerContainer.appendChild(div);

        // Create a new script element
        var script = document.createElement('script');
        script.id = 'dynamicScript';
        script.src = '{HOST}/merchantpgpui/offerjs/merchants/{MID}.js';
        script.type = "application/javascript";
        script.crossOrigin = "anonymous"; // Replace with your script URL

        // Define the onload event handler
        script.onload = function() {
            console.log('Script has been loaded with price: ' + price);
            // Configuration for the script
            var config = {
                "root": "#banner",
                "data": {
                     "accessToken": "ACCESS_TOKEN_HERE",
                    "referenceId": "ACCESS_TOKEN_REFERENCE_ID",
                    "amount": price,    // total cart value
                    "offerDiscoveryInfo": {
                        "amountBasedBankOffer": false,
                        "items": [
                             {
                        "id": "item1116",             //random identifier for item 
                        "productId": "2",             // SKU code configured in the merchant's DB
                        "brandId": "1707",            // Brand identifier assigned for the brand
                        "categoryId": "124",          // Category identifier assigned for the category
                        "model": "iphone_11_24",      // Model configured in the merchant's DB
                        "price": 10000.00             // price of the product
                      }
                        ],
                        "amountBasedSubvention": true
                    },
                    "userDetail": {
                        "mobileNumber": "1111111111"
                    }
                },
                "merchant": { "mid": "YOUR_MID_HERE"}
            };

            // Initialize the Paytm OfferJS library
            window.Paytm.OfferJS.onLoad(function() {
                window.Paytm.OfferJS.initLib(config.merchant.mid).then(res => {
                    window.Paytm.OfferJS.init(config).then(res => {
                        window.Paytm.OfferJS.invoke();
                    });
                });
            });
        };

        // Append the new script element to the document body
        document.body.appendChild(script);
    }

    // 
    var customElement = document.getElementById('<Element which determines dynamic behaviour>');
    customElement.addEventListener('input', function() {
        var newPrice = customElement.value;
        onScriptLoad(newPrice);
    });

</script>

<script type="application/javascript" crossorigin="anonymous" src="{HOST}/merchantpgpui/offerjs/merchants/{MID}.js" onload="onScriptLoad(price);"> </script>

 

Attribute details

Attribute Name

Description

root

The element where the banner will be injected.

accessToken

Token generated using Access Token API to be used for fetching offer related information

referenceId

The reference ID used to create the access token.

amount

The amount for which offers are to be fetched.

  • Incase of single item, it would be item price
  • Incase of multiple items, it would be sum of item prices

 

merchant

 

mid

Your MID

amountBasedBankOffer

Based on the type of offer created at Paytm, merchant has to set this parameter. 

  • Incase the offer has to be applied on the basis of transaction Amount, set this to true
  • Incase the offer has to be applied on the basis of the items in the cart, then set this to false

 

items

Incase the offer has to be applied by evaluation on the basis of items, then pass this item with the item details.

Include this if either bankOffer or EMI subvention or both are item-based. Provide information about the items/products included in the offer discovery, including details such as item ID, product ID, brand ID, category ID, model, and price

amountBasedSubvention

Based on the type of EMI Subvention created at Paytm, merchant has to set this parameter. 

  • Incase the subvention has to be applied on the basis of transaction Amount, set this to true
  • Incase the subvention has to be applied on the basis of the items in the cart, then set this to false

 

items parameters:

Parameter

Data Type

Mandatory

Description

items.id

String

Mandatory

Any unique identifier for one item in the request e.g. in case of 2 items in the cart, the values can be sent as 1234 and 1236.

items.productId

String

Mandatory

Unique product identifier for the merchant.

items.brandId

String

Mandatory

Product brand identifier for the merchant e.g. LG, Sony etc. Should be send in the request if EMI plans are configured with brand attribute.

items.categoryId

String

Mandatory

Product category identifier for the merchant (categories can be Electronics, footwears etc). This should be sent in the request with same value which is configured in the EMI plan.

items.price

Integer

Mandatory

Price of the product