Detect User Intent To Leave A Website

by Clayton Lambert

The Problem

A few days ago, I began work on deploying niche sites so that this server can help pay for itself. I used WordPress to setup two sites and both were up in a matter of minutes. There is a steady flow of traffic to each site (thanks to some social marketing techniques I will be covering soon), but most of this traffic was from users who visit once and then do not return. My initial thought was to just popup a newsletter form when the user stays for longer than (x) seconds.

However, I do not like the timed popup approach to showing a newsletter form because it often collides with the users experience. For instance, when a user is reading an article the article will may be covered by the newsletter form which interrupts the users ability to read my content. I could have just ignored it and used a timed popup, but instead I decided to venture out and think about how I could improve the implementation of my newsletter form.


  • – Don’t harm user experience
  • – Improve user retention rate

Detecting User Intent

I came to a pretty quick realization that the best time to display a form is when a user is already actively looking to leave your page. We’re not trying to trap the user; however, we are trying to coax the user into staying or subscribing to our newsletter so they can be returning visitors. This conclusion left me with one question. How do I detect users intent to leave my page?

For most, if not all browsers the back and close buttons are located at the top left and top right corners of the window. That means the user would have to move their mouse up and either to the right or left. So if we can detect the direction the users mouse is moving and knowing that the buttons to leave your site are located in the top corners, we have a basis for detecting the users intent to leave.

Along with the mouse detection, I also had the idea to display the newsletter when a user mouses over a link that will leave my site. I excluded any internal links like menus or anything that matches the hostname of the current page. I think it’s fair to say that a user who moves their mouse over an external link; is likely to click that link, which will result in a lost visitor.


My script is not perfect, it has it’s flaws. Currently, it’s just a proof of concept to an idea that could grow into something much greater. I believe this type of user intent detection could be useful for many web masters. Currently the detection is based on the way I use my browser. In the future, I would like to do a small study and record browser data from volunteers so I can see how their mouse patterns defer from mine. With this insight I could adjust the script to be more accurate based on the data… along with some other tweaks of course.

Know someone that would find this post interesting? Share it with them!
Share on Facebook
Tweet about this on Twitter
Share on Reddit
Share on Google+
Pin on Pinterest
Share on Tumblr
Share on StumbleUpon


  • ImpressTheNet says:

    Thanks! Looking forward to trying this out!

  • Add Comment