# Exit Intent on Mobile

On desktop, exit intent is detected by tracking the user's cursor as it moves toward the top of the browser window. On mobile devices, there is no cursor to track, so a different approach is needed.

#### How Mobile Exit Intent Works

Zigpoll uses scroll speed detection to infer exit intent on mobile:

1. The user's scroll position is continuously tracked.
2. When the user scrolls up, the scroll speed is measured.
3. If the speed exceeds a threshold, exit intent is triggered.

This works because mobile browsers require users to scroll upward to access the URL bar. Users tend to perform this action swiftly — much faster than scrolling up to read content — making it a reliable signal for exit intent.

#### Custom Implementation

If you want to implement your own mobile exit intent logic, you can use the [Javascript API](/javascript-api.md) to trigger a survey programmatically. Here's an example of scroll speed detection:

```javascript
function myScrollSpeedFunction() {
  const delta = my_scroll();
  if (delta < -80) {
    // Trigger your Zigpoll survey here
    window.Zigpoll.open();
  }
}

var my_scroll = (() => {
  let last_position, new_position, timer, delta, delay = 50;

  function clear() {
    last_position = null;
    delta = 0;
  }

  clear();
  return () => {
    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;
  };
})();

document.addEventListener('scroll', myScrollSpeedFunction);
```

You can adjust the threshold (default `-80`) to be more or less sensitive. You might also wait until the user has scrolled at least 50% down the page before initializing this script.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zigpoll.com/tutorials/exit-intent-mobile.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
