Direct Integration
Promotional messaging
Integrate promotional messaging

Integrate promotional messaging

TipTop.js

TipTop.js is a JavaScript library designed to simplify the integration of TipTop's promotional messaging into your website. It facilitates the rendering of promotional content and ensures smooth communication between the HTML tags you add to your site (like data-page-type) and TipTop's servers. By following the integration steps outlined below, you can leverage TipTop.js to effectively showcase TipTop's features to your customers.

Steps of integration

Step 1

The initial step to leveraging TipTop's promotional messaging capabilities involves incorporating the TipTop.js library within your website's global page template. This strategic placement guarantees that the library loads across all your site's pages.

Here's how to include TipTop.js:

  1. Locate the head section of your global page template.
  2. Paste the following embed code within the head section:
HTML
<script>
  var _tiptop_config = {
    public_api_key: "YOUR_PUBLIC_API_KEY",
    script: "https://cdn.tiptop.com/js/v1/tiptop.js",
  };
 
  !(function (t, e) {
    var n = t.tiptop || {},
      c = document.createElement("script");
    (c.async = !0), (c.src = e.script);
    var i = document.getElementsByTagName("script")[0];
    i.parentNode?.insertBefore(c, i), (t.tiptop = n);
  })(window, _tiptop_config);
</script>

Once you've successfully incorporated the TipTop.js library using the provided embed code, a dedicated TipTop instance will be established on your client-side environment. This instance acts as an intermediary between your website and TipTop's servers, facilitating communication and functionality.

Step 2

Following the inclusion of TipTop.js, you'll insert specific HTML tags within your website's code at locations where you desire TipTop's promotional messaging to appear. These designated tags are responsible for rendering (displaying) the messaging content.

For detailed information on the available HTML tags and their functionalities, visit our comprehensive HTML reference.

HTML
<div id="prices">
  <div id="checkout-button">Checkout</div>
  <div id="total-price">$50.00</div>
  <p
    class="tiptop-promo-widget"
    data-page-type="product"
    data-amount="1000"
  ></p>
</div>

The data-page-type attribute plays a crucial role in ensuring effective placement and configuration of TipTop's promotional messaging components within your website

Example

HTML
<!DOCTYPE html>
<html lang="en">
 
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product Detail Page</title>
    <script>
      var _tiptop_config = {
        public_api_key: "YOUR_PUBLIC_API_KEY",
        script: "https://cdn.tiptop.com/js/v1/tiptop.js",
      };
 
      !(function(t, e) {
        var n = t.tiptop || {},
          c = document.createElement("script");
        c.async = true;
        c.src = e.script;
        var i = document.getElementsByTagName("script")[0];
        i.parentNode.insertBefore(c, i);
        t.tiptop = n;
      })(window, _tiptop_config);
 
    </script>
  </head>
 
  <body>
    <main>
      <div class="product-detail">
        <h1>Product Name</h1>
        <div class="product-description">
          Product description.
        </div>
        <p>$100</p>
        <div class="tiptop-promo-widget" data-page-type="product" data-amount="1000"></div>
        <div class="checkout-buttons">
          <button class="cart-button">+ Add to cart</button>
          <button class="buy-now-button">Buy it now</button>
        </div>
 
      </div>
    </main>
  </body>
 
</html>