Common Issues
window.shoplift is undefined
Cause: Your script is running before Shoplift's script has loaded.
Fix: Use a polling pattern to wait:
function waitForShoplift(callback, maxAttempts = 50) {
let attempts = 0;
function check() {
if (window.shoplift) {
callback();
} else if (attempts < maxAttempts) {
attempts++;
setTimeout(check, 100);
} else {
console.warn('Shoplift did not load within the expected time.');
}
}
check();
}isHypothesisActive() always returns false
Possible causes:
The test is paused or inactive in the Shoplift dashboard
The hypothesis ID is incorrect (check for typos, copy it fresh from the dashboard)
The visitor doesn't meet the test's targeting criteria (e.g., wrong device type or country)
Merchant preview mode is active (check for
?isShopliftMerchant=truein the URL or sessionStorage keyShoplift_Session)
Debug:
If the URL parameter override works but normal assignment doesn't, the test configuration in the dashboard needs attention.
Variant shows briefly then disappears (flicker)
Cause: Your code applies the variant, but another script or page re-render overwrites it.
Fix:
Ensure your test code runs after the DOM element is stable
Use CSS transitions instead of immediate DOM manipulation
For elements loaded via AJAX, listen for the appropriate load/render event before applying the variant
Test data not appearing in analytics
Possible causes:
getVisitorData()is called before the visitor has been assigned to any testsYour analytics platform's script hasn't loaded yet
Consent hasn't been granted (if using
setAnalyticsConsent())
Fix: Ensure both Shoplift and your analytics platform are loaded before sending data:
Consent integration not working
Debug steps:
Verify your CMP is loaded:
console.log(typeof OneTrust)orconsole.log(typeof Cookiebot)Check consent state:
console.log(window.OnetrustActiveGroups)orconsole.log(Cookiebot.consent)Manually test:
await window.shoplift.setAnalyticsConsent(true)Verify:
console.log(window.shoplift.getVisitorData())
Last updated
Was this helpful?