The Hidden Cost of Discount Code Leaks
In the world of e-commerce, discount codes are a popular and effective way to attract new customers and reward loyal ones.

Many A/B tests count impressions/views/sessions on page load regardless of whether the user scrolls to that change or not.
This can lead to:
Here at Fabric Analytics, we recommend view-based tracking which ensures that only the users who could’ve been influenced by the test are counted.
By doing this, you:
We implement view-based tracking manually in to each test using the JavaScript Intersection Observer API, which will detect when an element enters the viewport and then fire the tracking.
Example code:
// This function logs a tracking event when an element is in view
function fireTrackingEvent(elementId, variant) {
console.log(`Element ${elementId} is in view. Firing tracking event for variant: ${variant}`);
}
// Create a new IntersectionObserver instance
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
// Check if the element is intersecting (in view)
if (entry.isIntersecting) {
const element = entry.target;
const elementId = element.getAttribute('id');
const variant = element.getAttribute('data-variant');
fireTrackingEvent(elementId, variant); // Fire a tracking event
observer.unobserve(element);
}
});
}, {
// Trigger the callback when 50% of the element is in view
threshold: 0.5
});
// Select all elements with the class 'element' and observe them
document.querySelectorAll('.element').forEach(element => {
observer.observe(element);
});
If you are using A/B testing in your field of work or know colleagues that do, I would highly recommend implementing view-based tracking as an additional event. You’ll soon find out how much that extra noise has been impacting your results.

In the world of e-commerce, discount codes are a popular and effective way to attract new customers and reward loyal ones.

Consent Mode V2 is a powerful tool in GA4 that ensures data collection respects user consent while still enabling effective analytics.

Before critiquing it, it’s important to be clear about what Google Tag Gateway actually is.