CRO / Conversion4 min read
How to Create an Exit-Intent Popup in Webflow
Learn how to create an exit-intent popup in Webflow: mouse detection, mobile scroll, and display frequency.
In this tutorial, Sandro, co-founder of Gemeos Webflow agency, shows you how to display an exit-intent popup in Webflow: it appears when the visitor is about to leave the page.
Example
Move your mouse up and off the page to trigger it
| Trigger | Device | Condition |
|---|---|---|
| Mouse up | Desktop | e.clientY <= 0 |
| Fast upward scroll | Mobile | Delta > 50px upward |
| sessionStorage | All | Shown only once per session |
1. Create the popup in Webflow
Create a Div with the ID exit-popup set to Fixed position, covering the entire page (top/left/right/bottom: 0), background rgba(0,0,0,0.5), display flex, align-items and justify-content center. Inside it, add your modal with your offer. Set the overlay to display: none by default. Add the exit-popup-close class to the close button.
2. Add the script in Footer code
(function() {
var shown = sessionStorage.getItem('exit-shown');
if (shown) return;
var overlay = document.getElementById('exit-popup');
if (!overlay) return;
function show() {
if (sessionStorage.getItem('exit-shown')) return;
overlay.style.display = 'flex';
sessionStorage.setItem('exit-shown', '1');
}
function close() {
overlay.style.display = 'none';
}
// Desktop: mouse leaving upward
document.addEventListener('mouseleave', function(e) {
if (e.clientY <= 0) show();
});
// Mobile: fast upward scroll (intent to leave)
var lastScroll = window.scrollY;
window.addEventListener('scroll', function() {
var delta = lastScroll - window.scrollY;
if (delta > 50 && window.scrollY < 200) show();
lastScroll = window.scrollY;
});
// Close
overlay.addEventListener('click', function(e) {
if (e.target === overlay) close();
});
document.querySelectorAll('.exit-popup-close').forEach(function(btn) {
btn.addEventListener('click', close);
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') close();
});
})();3. Customize the trigger
To trigger it only after X seconds on the page, add a minimum delay before activating the listeners:
// Activate exit intent only after 30 seconds
var ready = false;
setTimeout(function() { ready = true; }, 30000);
document.addEventListener('mouseleave', function(e) {
if (ready && e.clientY <= 0) show();
});Conclusion
Exit intent is one of the most effective lead recovery tools. Use cases:
- Last-chance offer on a pricing page
- Download a free guide before leaving
- Newsletter signup with an incentive
Move your mouse to the top of the page to trigger the popup
👀Waiting for the exit signal...
Wait!
Before you go, download our free guide to Webflow optimization.
Download the guideNo thanks, I’m leaving


