Test Triggers
Last updated
Was this helpful?
Was this helpful?
// Test triggers for ALL visitors immediately on page load
document.addEventListener('DOMContentLoaded', async () => {
const showNewHero = await window.shoplift.isHypothesisActive('hero-v2-id');
if (showNewHero) {
document.querySelector('.hero').innerHTML = newHeroContent;
}
// Even visitors who scroll past immediately are in the test
});// No test participation yet
button.addEventListener('click', async () => {
// Test participation triggered NOW, on first call
const isActive = await window.shoplift.isHypothesisActive('hypothesis-id');
// Visitor is now permanently assigned to a variant
});// Test only triggers when visitors actually open the cart
document.querySelector('.cart-icon').addEventListener('click', async () => {
// First click triggers test participation
const useNewCart = await window.shoplift.isHypothesisActive('cart-v2-id');
if (useNewCart) {
openNewMiniCart();
} else {
openStandardCart();
}
// Only cart users are in the test data
});