Browse docs
SDK

JavaScript SDK

Install, initialize, assign, and track — the browser SDK API.

The MaxLift browser SDK evaluates experiments locally with deterministic hashing — sub-millisecond, no network call per decision. It fetches a compiled ruleset once, caches it, and refreshes in the background.

Install

html
<script src="https://maxlift.io/api/sdk-ir" defer></script>

init(options)

javascript
MaxLiftSDK.init({ tenantId: 'YOUR_WORKSPACE_ID', // Settings → SDK credentials pollMs: 30000, // optional, ruleset refresh interval (min 5000) });

experiment(key, context)

Returns { variation, payload, reason }. Assignment is deterministic — the same user always gets the same variant. Pass a stable userId in context.

javascript
const { variation } = MaxLiftSDK.experiment('pricing_test', { userId: 'u_123', attributes: { country: 'US', deviceType: 'mobile' }, });

variation(key, context, default)

Convenience wrapper returning just the variant string, with a fallback.

javascript
const v = MaxLiftSDK.variation('pricing_test', { userId }, 'control');

track(key, metric, context)

Record a conversion for the user's assigned variant. Exposures fire automatically on assignment.

javascript
MaxLiftSDK.track('pricing_test', 'purchase', { userId });