How can I determine the exit intent in a mobile browser?

I am working on a solution to determine the intention to exit to Safari Mobile. (or any mobile browser for that matter)

On the desktop, I can track the movement of the cursor, and when the user breaks the plane of the web page, I can cause a pop-up window. See http://www.quicksprout.com/about/ for an example. Move the cursor up to the back button in the browser, and as soon as it closes the web page, a pop-up window will appear. How can I solve this in a mobile environment?

Is there a way to determine when someone clicks on the Safari address bar, and before the favorites screen appears, can I launch a popup?

Thank you in advance for your help.

+7
source share
3 answers

I know this is over a year later, but maybe my answer may help someone in the future.

On some of my sites, I found that the intention of a mobile exit often consists of a small scroll up before the user clicks on his button. For example, users often scroll down a little page, consuming content, but when they are ready to leave, they can scroll up a bit (say, 5-10% of the page height), and then they will go to the back or close the tab.

, -, . , - , 50% , , , 5%, , , , . Javascript, https://github.com/shahzam/DialogTriggerJS

, , , , !

+18

, window.onpagehide. .

, :

<!DOCTYPE html>
<html>
    <head>
        <script> window.onpagehide = function(e) { alert("Don't go! I'm lonely!"); }</script>
    </head>
    <body>
    </body>
</html>

, , , , , , Safari , . , , , , , ( ).

+2

, - , .

, , , . , , , , .,

  1. , . - Javascript, , "touchstart", , body:

    jQuery(document).on('touchstart', function(){
        $(body).addClass('on-mobile-device');
    });
    
  2. , "":

    function myScrollSpeedFunction(){
        if( jQuery('body').hasClass('on-mobile-device') ){ 
            if(my_scroll() < -200){
                //Your code here to display Exit Intent popup
                console.log('Must show mobile Exit Intent popup')
            }
        }
    }
    
    var my_scroll = (function(){ //Function that checks the speed of scrolling
    var last_position, new_position, timer, delta, delay = 50; 
    function clear() {
        last_position = null;
        delta = 0;
    }
    
    clear();
    return function(){
        new_position = window.scrollY;
        if ( last_position != null ){
            delta = new_position -  last_position;
        }
        last_position = new_position;
        clearTimeout(timer);
        timer = setTimeout(clear, delay);
        return delta;
    };
    })();
    
    jQuery(document).on('scroll', myScrollSpeedFunction );
    

. , , , .

, Exit Intent , , ., : https://majas-lapu-izstrade.lv/woocommerce-save-abandoned-carts-pro/, , .

0

All Articles