Skip to main content
Prerequisites — before implementing Anti-Bracketing, 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.
Anti-Bracketing is available on demand. If you’re unsure whether this feature is enabled for your account, contact your Kleep representative.

What Anti-Bracketing does

When a shopper adds two or more sizes of the same product to their cart, Anti-Bracketing opens a prompt asking them to commit to one size. It can optionally display Kleep’s AI size recommendation to help them choose confidently. The prompt appears as a side panel (sliding in from the right) or a modal (centered overlay), depending on your configuration. Shoppers can always dismiss it and keep all sizes.

How to implement

Step 1: Wait for the SDK The kleep.antiBracketing method is available once the widget script has loaded. Wait for it before initializing:
Step 2: Initialize with your cart adapter The adapter tells the widget how to read your cart and (optionally) remove lines.
The getCart callback must return all cart lines with productId, variantId, quantity, and size. The widget groups lines by productId to detect bracketing — if two lines share the same productId with different sizes, the prompt will trigger.
Step 3: Start listening
This starts the reconcile loop. The widget will call getCart, detect bracketing, and show the prompt when appropriate. Step 4: Notify on cart changes Call notifyCartChanged() whenever the cart is updated (add to cart, remove, quantity change) so the widget re-checks:
Call this after every cart mutation — add to cart, remove from cart, quantity change. The widget will re-read the cart via your getCart adapter and react accordingly.
Step 5: Handle the shopper’s choice
If you provided setLineQuantity in the adapter, the SDK removes the unkept lines automatically (applied will be true). Otherwise, handle removal in the resolve callback. Step 6: Cleanup

Full example

Configuration

All visual settings — trigger frequency, layout, wordings, content toggles — are managed from the Kleep dashboard at AI Sizing → Anti-bracketing. The widget reads them from the Kleep CDN at runtime, so you do not need to pass them in code. You can override specific settings at initialization time if needed:
See the Reference section below for the full list of parameters.

Reference

Initialization parameters

Adapter contract

The adapter tells the widget how to read and modify your cart.

Instance methods

Events

Style options

Visual overrides passed via config.style:

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.