JavaScript Integration Guide

This guide describes how to integrate Uniqodo's promotion engine in the front end of your eCommerce website using our JavaScript tags.

📘

Please note that this is an alternative promotion engine integration method to the backend integration that utilises our APIs. See our API reference for instructions on how to integrate Uniqodo into your backend systems using our REST APIs. However, Onsite Experiences will always need the tag integration irrespective of the promotion engine integration method.

Uniqodo frontend integration is made up of two JavaScript tags that work together to validate and redeem promotional codes. These tags need to be added to the retailer’s website.

The purpose of each tag is described in the table below:

Tag NamePurpose
Visit tagTo integrate coupon code validation and redemption. This tag is also used to enable onsite experiences (overlays, banners etc.) to be displayed to customers on the eCommerce website.
Redemption tagFor recording orders or transactions against a coupon code once it has been used to complete a purchase.

🚧

Important Note

Both the visit and the redemption tags should be set as strictly necessary in relation to your site's cookie policy. This ensures that the coupon code functionality is always present and our technology can run as intended.

The visit and redemption tags should only be fired once on initial page load, this includes Single Page Applications (SPA).


Visit Tag

The following script tag should be added to every page where a coupon code form exists or unique codes will be issued to customers. To avoid additional integration work in the future we advise clients to add this tag to every page on the eCommerce website except on pages where The Redemption tag is present.

The Visit tag allows Uniqodo to configure, control and validate unique codes entered in the code entry fields. It is also required on pages where onsite experiences or messages will be displayed to customers.

You need to install this tag if you intend to;

  1. Use Uniqodo's promotion engine to validate and redeem codes
  2. Use our onsite experience technology (overlays, banners, inline HTML elements) to issue unique codes or display promotional messages to customers on the website.
  3. Automatically populate the code entry field with unique codes when customers are redirected to the eCommerce website with a unique code in the URL.

<script type="text/javascript" async="" src="https://www.uqd.io/YOUR_UNIQODO_ID_HERE.js"></script>

Redemption

The following script tag should be added to every transaction confirmation page and set to display whenever a transaction is completed. It should be added just before the closing HTML </body> tag.

The Redemption tag is used to record the occurrence of a successful transaction. It is also for determining whether a given code needs to be expired following its redemption, which depends on the usage limit arranged for that code.

When the given code is valid for one use only, the tag immediately expires the code following a redemption. When the given code is valid for more than one use, the tag tallies each redemption against the usage limit, only expiring the code once the limit is reached.

Various pieces of information are required to enable this code to function, see the table below for more information on what values are required and how to integrate them.

🚧

Important

The Redemption tag must be set to fire when an order is confirmed - typically on the order confirmation page. It must be loaded on every transaction confirmation page, including responsive and mobile optimised versions of the page. If the tag is absent, Uniqodo will be unable to record and respond to transactions, and deactivate codes as necessary.

<script type="text/javascript">
    UNIQODO = typeof UNIQODO !== "undefined" ? UNIQODO : {};
    UNIQODO.orderConfirmation = true;
    UNIQODO.orderId = "ORDER_ID_HERE";
    UNIQODO.orderValue = "ORDER_VALUE_HERE";
    UNIQODO.discount = "DISCOUNT_AMOUNT_HERE";
    UNIQODO.delivery = "DELIVERY_HERE";
    UNIQODO.triggerCode = "TRIGGER_CODE_HERE";
    UNIQODO.currency = "CURRENCY_HERE";
    UNIQODO.cg = "COMMISSION_GROUP_DATA_HERE";

    // additional merchant custom data if required
    UNIQODO.p1 = "YOUR_VALUE_HERE"; 
</script>

<script type="text/javascript" async="" src="https://www.uqd.io/YOUR_UNIQODO_ID_HERE.js"></script>

📘

Notes on placeholders

The parameter placeholders in CAPS above (e.g. ORDER_ID_HERE) must be replaced with the relevant values for the order.

The section - "YOUR_UNIQODO_ID_HERE" - should be replaced with your Uniqodo account ID. This value will be supplied in an email but is also available on the “Setup” page in your Uniqodo account.

E.g. if your Uniqodo ID is 1234 then the tag URL should be:

The table below details the parameters for the Redemption tag.

ParameterDescriptionRequired?FormatExample
UNIQODO.orderIdThe unique ID of the order or booking in the retailer’s systemYesString15ABC1234
UNIQODO.orderValueThe total value of the order prior to any discount and excluding delivery costs. If the transaction is a lead type the value should be set to an empty string '' YesNumber25.99
UNIQODO.discountThe discount value that the customer received for the order. If there is no discount applied to the transaction then this parameter should be set to an empty string ''NoNumber15.00
UNIQODO.deliveryThe delivery or shipping charge the customer has paid on the order. If there is no delivery charge for the transaction it should be set to an empty string ''NoNumber5.00
UNIQODO.triggerCodeThe discount code applied to the transaction by the eCommerce platform. If this value is not available then it can be set to an empty string ''YesStringSUMMER10
UNIQODO.currencyThe three-digit ISO 4217 currency code for the transaction currencyNoStringGBP
UNIQODO.cgCommission group value. This is required for Awin advertisers and it should hold exactly the same value as the AWIN.Tracking.Sale.parts parameter.NoStringTV:500.00
UNIQODO.p1
UNIQODO.p2
...

UNIQODO.p21
Custom parameters used for additional order data for reporting and data analytics purposes.

Use these custom parameters (p1 up to p21) to hold transactional data that you would like Uniqodo to record against the order.

You can pass up to a maximum of 21 custom parameters per order. The values can be a number or a string. E.g.

UNIQODO.p1 = 44.55;
UNIQODO.p2 = "Europe";
NoString or Number

📘

Notes on multiple codes

Where multiple codes can be accepted on a single transaction the triggerCode should be be supplied in a single parameter and can be separated with the following delimiter:

|

The delimiter should only be used when there are multiple values in the parameter.

E.g.

triggerCode=“SALE10”

triggerCode=“SALE10|SALE20"

Content Security Policy (CSP)

If your website uses a content security policy you will need to add domain names to your current policy so that the relevant Uniqodo tags will be allowed to function.

The HTTP headers must include the following domain names:

  • *.uniqodo.com
  • *.uqd.io
  • *.promotionx.io

📘

See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more information on content security policies for websites.