window.shoplift
The global Shoplift API object and entry point for all client-side functionality.
window.shoplift
Availability
// The object exists on window after script initialization
typeof window.shoplift // 'object' when loaded, 'undefined' before
// Always guard access
if (window.shoplift) {
// Safe to use
}Object Shape
interface ShopliftAPI {
/**
* Check if the current visitor is assigned to a specific test variant.
* Returns true for variant (B), false for control (A).
*/
isHypothesisActive(hypothesisId: string): Promise<boolean>;
/**
* Manually set visitor analytics consent.
* Only needed for custom consent management platforms.
*/
setAnalyticsConsent(consent: boolean): Promise<void>;
/**
* Retrieve visitor information and test assignments.
* Synchronous — returns data immediately.
*/
getVisitorData(): VisitorData;
}Methods
Method
Description
Async
Details
Loading Behavior
Waiting for the Object
Polling (recommended)
Inline Guard
Error Handling
Browser Compatibility
TypeScript
Last updated
Was this helpful?