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)
javascriptMaxLiftSDK.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.
javascriptconst { 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.
javascriptconst 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.
javascriptMaxLiftSDK.track('pricing_test', 'purchase', { userId });