Skip to main content
The Promotions UI JS SDK automatically applies location-based discounts to prices on your page and renders a customisable banner that tells visitors about their local deal. It works with plain HTML — no framework required.
This SDK is separate from the entitlements JS SDK. Use this SDK when you need PPP / country-based discount banners and price display.

Installation

1. Add the Script

Paste this snippet just before the closing <head> tag on your pricing page:

2. Initialize the SDK

Copy your promotion ID from the promotion detail page and call init():
Copy promotion ID
This will automatically display a discount banner if the visitor is eligible for a discount.
Never expose your Server API Key in the browser. Use the Client API Key, which is safe for client-side code. You can find both keys under Settings → API keys in the Kelviq dashboard.

init() options


Auto price update

After init() resolves, every element with data-kq-price on the page is automatically updated with the discounted price for the visitor’s country.

Basic usage

The original-price element is hidden by default. The SDK shows it automatically when a discount is active and hides it when the visitor’s country has no discount.

Price container attributes

Sub-element attributes

Place these inside a price container to receive individual parts of the formatted price:

JS API

All methods return Promises and require init() to have been called first.

getUpdatedPrice(price, options?)

Computes the discounted price and returns a PriceObject without touching the DOM.
Parameters Returns — PriceObject

updatePriceElement(element, options?)

Updates a specific DOM element with the computed discounted price. The element must have a data-kq-price attribute. All elements linked to it via data-kq-rel are updated as well.
Parameters Returns a PriceObject (same shape as getUpdatedPrice).

updatePrice(configs[])

Batch-update multiple elements, optionally rendering each with an HTML template.
Config object fields Available template variables (any field from PriceObject): {{price}} · {{formattedPrice}} · {{integerPart}} · {{decimalPart}} · {{decimalSeparator}} · {{currencySymbol}} · {{currencyCode}} Returns Promise<PriceObject[]> — one entry per config.

CSS hooks

The SDK adds classes to document.body that you can target in your stylesheets:

Sandbox

Set environment: "sandbox" to test against the Kelviq sandbox environment.
Use sandbox API keys (available under Settings → API keys with the Sandbox toggle enabled) so real visitor data is never affected during testing.