Debugging & Testing

URL parameters, console commands, and troubleshooting for Shoplift JavaScript API tests.

Debugging & Testing

Tools and techniques for verifying your Shoplift JavaScript API implementation during development and QA.

URL Parameters

Append these to any page URL to control Shoplift's behavior without modifying code.

Parameter
Effect

?slVariant=<hypothesisId>

Forces isHypothesisActive() to return true for the specified hypothesis

?isShopliftMerchant=true

Disables all Shoplift functionality on the page

Examples

Force a specific variant:

https://yourstore.com/products/example?slVariant=aa800953-3e22-4335-a53b-50f61db17538

Force all variants active (useful for visual QA):

https://yourstore.com/?slVariant=true

Disable Shoplift entirely (useful for debugging non-test issues):

https://yourstore.com/?isShopliftMerchant=true

Console Commands

Run these in your browser's developer console (F12 or Cmd+Option+I) to inspect Shoplift's state.

Check if Shoplift is loaded

Inspect visitor data

View visitor data as a table

List all active test assignments

Test a specific hypothesis

Common Issues

window.shoplift is undefined

Cause: Your script is running before Shoplift's script has loaded.

Fix: Use a polling pattern to wait:

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)

  • Shoplift functionality is disabled via ?isShopliftMerchant=true

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 tests

  • Your 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:

Debug steps:

  1. Verify your CMP is loaded: console.log(typeof OneTrust) or console.log(typeof Cookiebot)

  2. Check consent state: console.log(window.OnetrustActiveGroups) or console.log(Cookiebot.consent)

  3. Manually test: await window.shoplift.setAnalyticsConsent(true)

  4. Verify: console.log(window.shoplift.getVisitorData())

QA Checklist

Use this checklist when verifying a new JavaScript API test implementation:

Last updated

Was this helpful?