Skip to main content
Prerequisites — before implementing AI Sizing, complete the Cookie consent and Installation steps on the JS Library page. Kleep must not load until the visitor has consented via your CMP, and the library must be loaded site-wide.

Methods

kleep.load — Display Kleep’s CTA

  1. Initialize the widget with kleep.load:
  2. Add a container where the widget should be displayed on the product page:
This div is used to append our button inside. We leave CSS styling of the button to you during the implementation.

Parameters

kleep.load should be called on each product page (PDP) to load Kleep’s CTA, with the following parameters:
If lang or market don’t follow their respective conventions or aren’t supported, you’ll see a console warning.
Matching product_id with selectors.sizing. These two control which product is shown in which container, so they have to line up:
  • One product in one or several containers → pass product_id as a single string. The same product is applied to every selector in selectors.sizing.
  • Different products, one per container → pass product_id as an array with the same length as selectors.sizing. They are paired by index, so the order must match (product_id[0] → selectors.sizing[0], and so on).
If product_id is an array whose length is different from selectors.sizing, no CTA is rendered at all and a warning is logged in the console (it prints both lengths and values). For example, product_id: ["sku-1"] (1 item) with two selectors fails silently — fix it by repeating the id (["sku-1", "sku-1"]) or passing it as a string ("sku-1").
If a language you need isn’t in the list below, please contact your Kleep representative.
  • fr — French (default)
  • ar — Arabic
  • br — Brazilian
  • da — Danish
  • de — German
  • el — Greek
  • en — English
  • es — Spanish
  • fi — Finnish
  • hu — Hungarian
  • id — Indonesian
  • it — Italian
  • ja — Japanese
  • ko — Korean
  • nl — Dutch
  • pl — Polish
  • pt — Portuguese
  • ru — Russian
  • sv — Swedish
  • th — Thai
  • vi — Vietnamese
  • zh — Chinese (Simplified)
  • zht — Chinese (Traditional)
Regional tags are accepted too (en-GB, fr_CA…): zh-TW, zh-HK and zh-Hant select Traditional Chinese.
Editing widget copy per language. Once integrated, you can fine-tune the widget’s default text - button labels, intro copy, consent notices, etc. - for each of your supported languages directly from your Kleep Dashboard. See Web Translations.
AF, AX, AL, DZ, AD, AO, AI, AG, AR, AM, AW, AC, AU, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BA, BW, BV, BR, IO, BN, BG, BF, BI, KH, CA, CV, BQ, KY, CF, TD, CL, CN, CX, CC, CO, KM, CG, CD, CK, CR, HR, CU, CW, CY, CZ, CI, DK, DJ, DM, DO, EC, EG, SV, GQ, ER, EE, SZ, ET, FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GH, GI, GR, GL, GD, GP, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, KP, XK, KW, KG, LA, LV, LB, LS, LR, LY, LI, LT, LU, MO, MG, MW, MY, MV, ML, MT, MQ, MR, MU, YT, MX, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NL, AN, NC, NZ, NI, NE, NG, NU, NF, MK, NO, OM, PK, PS, PA, PG, PY, PE, PH, PN, PL, PT, QA, CM, RE, RO, RU, RW, BL, SH, KN, LC, MF, PM, WS, SM, ST, SA, SN, RS, SC, SL, SG, SX, SK, SI, SB, SO, ZA, GS, KR, SS, ES, LK, VC, SD, SR, SJ, SE, CH, SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TA, TN, TR, TM, TC, TV, UG, UA, AE, GB, US, UM, UY, UZ, VU, VE, VN, VG, WF, EH, YE, ZM, ZW, ZZ

Example

While implementing, you can use this test config:
  • public_id: "aadb1934-6e16-4c8a-a7cb-1fd6e00dd02c"
  • product_id: "12345"
  • variantIds to use for the callbacks (with their corresponding size label):

Custom callbacks

Besides getSizes, addToCart and selectSize, kleep.load accepts custom callbacks under callbacks. They work the same way: a button in the drawer, and when the visitor clicks it, Kleep calls your function. Each custom button is set up by Kleep for your account during onboarding (label, translations, and when it appears — for example when the recommended size is out of stock); you only implement the function. Each callback receives the variantId of the size the visitor was looking at (null when getSizes isn’t implemented), and a second argument with productId and size.
Call kleep.requestSize on each product page to get the visitor’s recommended size for that product, without opening the drawer. It is meant to be called on every PDP, including products Kleep can’t size: it then resolves with success: false and you display nothing. It works in two modes:
  • Return only — Kleep returns the recommended size and you build your own element and wording around it.
  • Fill an element — you pass a selector; Kleep writes the recommended size into that element as plain text (not a button), with the same wording as the “Recommended size” state of the CTA created by kleep.load, translated in the page’s lang. When there is nothing to display, the element is emptied if Kleep had filled it before (a previous product on a single-page app), and left untouched otherwise. When several calls target the same element, the latest one wins.

Parameters

Return value

A Promise resolving to an object. It never rejects: errors resolve with success: false. A product needs one or more fit areas: tops need top, trousers and skirts need bottom, dresses and jumpsuits need both, shoes need shoes. The drawer only asks the questions of the areas the product needs, and the visitor’s profile grows as they answer about new areas. kleep.requestSize tells you where the visitor stands for the product displayed:
kleep.requestSize only reads the visitor’s existing Kleep profile: it never opens the drawer or asks questions, and it returns sizes only — never the visitor’s measurements or identifiers. Call it again when the product displayed changes (single-page apps) or after the drawer closes, so the label follows the latest profile.

kleep.createButton — Recreate Kleep’s CTA

In some cases your website might rebuild components or reload state variables, causing Kleep’s CTA to disappear. Call kleep.createButton to make it reappear. No parameter is needed — it reuses the information you provided when calling kleep.load, so make sure kleep.load ran first.

kleep.track — Enable tracking & Dashboard access

On top of the sizing functionality, we add tracking so you can measure how the solution performs on your website. Use kleep.track(event_type, event_info) to send information each time a tracked event occurs.
These events track your store’s standard customer journey — a product being viewed, added to cart, or purchased through your usual storefront flow. They are not Kleep-specific actions (e.g. an add-to-cart triggered from the Kleep widget); fire each one wherever it naturally happens on your site.
kleep.track needs your public_id. Set data-public-id on the script tag on every page, including the cart and confirmation pages, which don’t call kleep.load.
We track three events: Use the ids of your product feed: A call with a missing key, or with an event name Kleep doesn’t know, is refused. It is not counted in your dashboard. The browser console gives the missing keys.

product_viewed

product_added_to_cart

checkout_completed

Cart items

Each entry of cart is one line of the cart (product_added_to_cart) or of the order (checkout_completed).
price.amount is the unit price, never the line total. Kleep computes the amount of a line as price.amount × quantity, and the amount of an order as the sum of its lines. For two units at 50 €, send amount: "50" and quantity: 2: the line counts for 100 €. Sending amount: "100" with quantity: 2 would count it for 200 €.
An ID sent as a number is read as text: 12345 and "12345" are the same ID.

A/B test group (experiment)

When you run your own A/B test (for example on the try-on), add the visitor’s group to each event in the experiment field, as { name, variant } or the text "name:variant" (1 to 64 characters, no space). It is the same value as the experiment parameter of kleep.vto, and the only way for Kleep to count the visitors of a group that never uses the tested feature (a control group).
experiment is optional and accepted on every event. See Experiment groups for the format and for what to send for each group. The A/B test that Kleep runs on the size CTA doesn’t need it.

kleep.getTrackingId — Get internal Kleep ID

For custom use cases, you can retrieve one of the visitor’s Kleep internal IDs. It returns either:
  • null — if the visitor has not used Kleep, or
  • a UUID — if the visitor has a Kleep tracking ID

Journeys and profiles

The drawer shows the questions of the product’s category (clothing, shoes, lingerie, children), decided by Kleep from your catalogue and account settings. The shopper’s profile follows them from one product to another on the same browser. On request, Kleep keeps one clothing profile per gender: a size found on a women’s product is then never shown on a men’s one. Contact your Kleep representative to enable it.

A/B testing

Kleep can run an A/B holdout test on your website: part of your shoppers see the Kleep CTA (group test), the others don’t (group control). You start and stop it from your Kleep dashboard, see A/B testing. You have no code to add, with three things to check:
  • Member ID: pass customer_id to kleep.load on every page where the shopper is signed in, with the same value as in your iOS and Android apps, character for character. Shoppers who aren’t signed in get a group stored in their browser.
  • Order page: load the Kleep script and send checkout_completed on the order confirmation page, for both groups.
  • Consent: while a test runs, PostHog is loaded for shoppers in the test. See Cookies & data privacy.
If the group can’t be read (network error, ad blocker), the CTA is shown. To check both groups, add ?kleep_ab=control or ?kleep_ab=test to the product page URL while a test is running.

Cookies & data privacy

Kleep is fully gated by visitor consent: the script only loads after consent is collected through your CMP, and you must condition its loading accordingly. For the complete list of trackers, the data processed, the purposes and legal bases, hosting, subprocessors and security, see Cookies, CMP & Data Privacy.