MetaSurvey
Help Center

Exit Intent Popup

Exit intent popups engage visitors who are about to leave your site. By triggering a survey popup when users show exit intent, you can gather feedback and retain visitors. Follow these steps to set it up:

  1. Get Your Popup Embed Code:

Navigate to your survey -> click Share menu -> select Embed on website -> select Popup -> click Copy code.

  1. Add the JavaScript Snippet:

Once you have the embed code, you can add the following JavaScript snippet to your website. Please add this under your Popup embed code.

<script>
  let exitIntentDetected = false;

  window.addEventListener("mouseout", (event) => {
    if (!exitIntentDetected && event.clientY < 0 && event.relatedTarget === null) {
      const msBtn = document.querySelector('[id^="metasurvey-button"]');
      if (msBtn) {
        msBtn.click();
        exitIntentDetected = true; // Prevent multiple triggers
      }
    }
  });

  // Hide the button
  /*window.addEventListener("load", () => {
    const msBtn = document.querySelector('[id^="metasurvey-button"]');
    if (msBtn) {
      msBtn.style.display = "none";
    }
  });*/
</script>

You can also uncomment the following lines to hide the call-to-action button (remove /* at the beginning and */ at the end):

/*window.addEventListener("load", () => {
  const msBtn = document.querySelector('[id^="metasurvey-button"]');
  if (msBtn) {
    msBtn.style.display = "none";
  }
});*/
  1. Test on Your Website:

Finally, test your website to ensure that the survey popup appears when you exhibit exit intent (try to close the browser tab).

All help articles