Experiment Issues

Missing Conversion Tracking Due to Event Blocking

Fix Missing Conversion Tracking: Enable Early Event Detection

THIS ARTICLE WILL HELP YOU:

Issue Overview

Convert’s tracking script captures conversion events based on user interactions, such as clicks and form submissions. It does this by attaching a single event listener to the document, allowing it to track events at a high level.

However, if other scripts on your website use event.stopPropagation() or event.stopImmediatePropagation(), they can prevent events from bubbling up to our listener. This interference means our script may fail to detect interactions, leading to missing conversion tracking.

How to Check if Event Propagation is Blocked

If you suspect event blocking is affecting your tracking, you can run the following test in your browser’s developer console:

const element = document.querySelector('ELEMENT_SELECTOR');
if (element) {
  element.addEventListener('click', (event) => {
    console.log('Event captured'); 
    // If you see this message in the console when clicking the element, 
    // event propagation is NOT blocked.
  });
}

Replace ELEMENT_SELECTOR with the actual selector of the element you want to test. If you do not see "Event captured" in the console, another script is likely blocking event propagation.

Solution: Enabling Early Event Detection

To ensure our script captures interactions before they are blocked, Convert now supports early event detection using event capturing. You can enable this by adding the following code snippet to your Global JavaScript configuration:

// GlobalJS
_conv_q.push({
  what: 'setParameters',
  params: {
    interceptEventsEarly: true // Activate early event detection
  }
});

How It Works

By enabling this setting, Convert’s tracking will listen for interactions before they reach the target element, preventing issues caused by stopPropagation().

Important Considerations

While this setting resolves most tracking issues, be mindful of the following:

Broader Event Detection

  • This feature captures all interaction events, not just those on your target elements.
    Recommendation: Ensure that your goals are configured with specific selectors (e.g., unique IDs or class names).

Potential Script Conflicts

  • If other scripts also use event capturing, the execution order may be unpredictable.
    Recommendation: Thoroughly test in preview mode before deploying.

Performance Impact

  • Capturing all interactions site-wide may affect performance in highly complex applications.
    Recommendation: Enable this feature only if tracking gaps occur.

Final Thoughts

If your goals are missing conversions due to event blocking, enabling early event detection can resolve the issue. However, always test carefully to avoid unintended side effects.