Detect that user is going to leave the page
I would like to detect when the user is going to leave the page, in order to show him a pop-up. I see this in many pages, but I don't know which is the best way to detect this. Anyone knows how to do it?
Detecting if a visitor wants to leave your site without disrupting their flow if they don't is quite difficult to accomplish, so it's probably best to use a exit intent tool for such overlays.
Hope this helps,
However, whe I call the function which is described on the extenal JS, I get the error "ouibounce is not defined",so I suspect that is not loading properly the JS
You'll need to make sure the file has finished downloading before you try to use it. Luckily, there is a callback function that fires as soon as the download is finished, so you need to move all your code into this callback function, like so:
Hope this helps!