doAction( “exit_intent” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Actions
  6. doAction( “exit_intent” )
doAction( "exit_intent", reason );

The exit_intent action is triggered when an exit-intent is detected. That is true, even when no Exit-Intent Area is present on the current page.

Params

reason
(string, required) The reason, why the plugin thinks that the user might want to leave the page.

Examples

// Example 1: Display exit-intent counter in H1 heading.
DiviArea.addAction( 'exit_intent', function(reason) {
    var h1 = jQuery( 'h1:first' );
    var count = h1.data( 'exit-intent-count' ) || 1;

    h1.data( 'exit-intent-count', count + 1 );
    h1.text( 'Exit-Intent number ' + count );
});
// Example 2: Open one of two areas on exit-intent.
DiviArea.addAction( 'exit_intent', function(reason) {
    var area1 = DiviArea.getArea( 'first-area' );

    if ( 'done' !== DiviArea.Utils.getLocalData( 'area-1-state' ) ) {
        DiviArea.show( area1 );

        // Mark the first-area as "done" for 60 minutes.
        DiviArea.Utils.setLocalData( 'area-1-state', 'done', 60 );
    } else {
        DiviArea.show( 'second-area' );
    }
});

Notes

Possible reasons can be:

mouse-leave
The mouse was moved upwards out of the browser. Only possible on devices with a mouse pointer.
swipe-up
The user did swipe upwards quickly. This is a typical indicator on iOS devices.

Illustration of the “mouse-leave” action:

Exit-Intent sample

Was this article helpful?

Related Articles