Heap
Quick Start
// Heap + Shoplift Integration
function initializeShopliftHeap() {
if (window.shoplift && window.heap) {
const visitorData = window.shoplift.getVisitorData();
if (visitorData.visitor && visitorData.visitorTests.length > 0) {
// Add user properties (works on both anonymous and identified users)
const properties = {
shoplift_visitor_id: visitorData.visitor.id,
shoplift_device: visitorData.visitor.device,
shoplift_first_seen: visitorData.visitor.createdAt.toISOString()
};
// Only add country if present
if (visitorData.visitor.country) {
properties.shoplift_country = visitorData.visitor.country;
}
// Add test assignments as properties
visitorData.visitorTests.forEach(test => {
properties[`test_${test.testId}`] = test.hypothesisId;
properties[`test_${test.testId}_type`] = test.isThemeTest ? 'theme' : 'element';
properties[`test_${test.testId}_assigned`] = test.createdAt.toISOString();
});
heap.addUserProperties(properties);
// Track test exposure events
visitorData.visitorTests.forEach(test => {
heap.track('Shoplift Test Exposure', {
test_id: test.testId,
variant_id: test.hypothesisId,
is_theme_test: test.isThemeTest
});
});
}
} else {
setTimeout(initializeShopliftHeap, 100);
}
}
// Initialize on page load
initializeShopliftHeap();
initializeShopliftHeap();Retroactive Analysis
Define Events After the Fact
Build Test-Specific Funnels
Create Variant Cohorts
Visual Labeling
Best Practices
Last updated
Was this helpful?