Exit Intent Tracking: How to Detect When Visitors Are About to Leave
Most of your website's visitors leave without taking any action. Understanding why — and being able to identify the exact moment a visitor switches from engaged to departing — is one of the more powerful capabilities in modern web analytics. Exit intent tracking is the practice of detecting behavioral signals that indicate an imminent page departure and using that information either to intervene in real time or to diagnose abandonment patterns after the fact.
What Signals Indicate Exit Intent
Exit intent is inferred from behavioral signals rather than observed directly. No JavaScript event fires when a visitor makes the cognitive decision to leave — you can only observe the physical actions that tend to precede departure.
- Mouse leaving the viewport: On desktop, moving the cursor rapidly toward the top of the browser window — toward the address bar, tab bar, or close button — is the strongest exit signal. This is what most exit-intent popup tools use as their trigger. It correlates with about 70-80% accuracy to actual page departures.
- Back button press: The
popstateorbeforeunloadevents fire when the visitor presses the browser back button. You can listen for these to know the visitor is actively navigating away. - Idle timeout: A visitor who has not moved their mouse, scrolled, or interacted with the page for several minutes is either deeply reading or has abandoned the tab. Idle events after a content-appropriate reading time threshold are a soft exit signal.
- Rapid scroll to bottom: Someone who scrolls quickly to the end of a long page without pausing has likely scanned the content and not found what they wanted. This is an exit signal especially when followed immediately by departure.
- Tab visibility change: The
visibilitychangeevent fires when the user switches to another tab. Followed by a long inactive period, this is a strong abandonment signal.
Implementing Exit Intent Events
To track exit intent in your analytics as a measurable event, add this to your page JavaScript:
let exited = false;
document.addEventListener('mouseleave', (e) => {
if (e.clientY <= 0 && !exited) {
exited = true;
_st('event', 'exit_intent', 'engagement', document.title);
}
});This fires once per page load when the cursor exits through the top of the viewport, recording which page the visitor was about to leave.
Combine this with your existing scroll depth data to understand whether visitors who trigger exit intent have actually read the page or are leaving before engaging with the content at all.
Using Exit Data to Diagnose Abandonment
The diagnostic value of exit intent data comes from comparing pages. If 60% of visitors on your pricing page trigger exit intent without converting, but only 20% do so on your features page, the pricing page has a problem that the features page does not — likely a mismatch between the visitor's expectations and what they find at that stage.
Segment your exit intent events by traffic source. Paid traffic that exits at high rates from your landing pages is traffic that was mis-targeted — the ad copy set expectations the page did not deliver. Organic traffic that exits from the same pages at lower rates suggests the problem is the ad creative, not the page.
Look at the sequence of pages that precede high-exit-intent pages using page flow analysis. If visitors consistently exit from page C after visiting pages A then B, the transition from B to C is a friction point — either the link is misleading about what page C contains, or page C fails to deliver on the context set by page B.
Track abandonment signals with statpx custom events
statpx custom events let you log exit intent, idle timeouts, and back-button presses so you can see exactly where your site loses visitors and why.
Start for free →The Bottom Line
Exit intent tracking transforms departing visitors from a lost statistic into a diagnostic signal. By capturing the behavioral patterns that precede page abandonment — upward mouse movement, back-button presses, rapid scanning — you can identify which pages lose visitors earliest, which traffic sources send visitors who leave before engaging, and where your content or user experience fails to hold attention. The data will not fix those problems for you, but it will tell you precisely where to look and which changes to prioritize.