doAction( “exit_intent” )

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

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

This action has no params.

Examples

// Example 1: Display exit-intent counter in H1 heading.
DiviArea.addAction( 'exit_intent', function() {
    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() {
    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

This action is triggered every time the mouse cursor is moved upwards outside the current browser page.

Was this article helpful?

Related Articles