Don't have one? Create one ↗
← All courses

Lesson 14 of 15

Exit Intent

Intermediate

Catch the mouse leaving toward the top of the window and fire an exit event.

① Connect your GTM container

Paste your container ID to load it into this page. It only ever runs here.

Advanced: use a specific environment
1

Goal

Detect exit intent, the cursor darting to the very top of the window, and push exit_intent. Great for triggering a save-offer modal.

  • Move your cursor up to the top edge

Listen to mousemove, check e.clientY <= 10, and fire only once.

2

Build it in GTM

  1. Add the exit-intent listener

    There's no built-in exit-intent trigger, so a small Custom HTML tag watches the cursor and pushes its own event.

    1. Go to Tags → New and choose Custom HTML.
    2. Paste a script that adds a mousemove listener and pushes { event: 'exit_intent' } when e.clientY <= 10, firing only once.
    3. Set its firing trigger to All Pages, name it Listener - Exit intent, and Save.
  2. Create the Custom Event trigger

    1. Go to Triggers → New and choose Custom Event.
    2. Set Event name to exit_intent (it must match the event you pushed).
    3. Name it Event - exit_intent and Save.
  3. Attach a tag

    1. Go to Tags → New and choose your save-offer modal tag, or a Custom HTML test tag with <script></script>.
    2. Under Triggering, add Event - exit_intent, then Save.
3

Debug in Tag Assistant

Open the live version of this lesson, that is the page you point Tag Assistant at. It has the clickable elements next to a live dataLayer, so this page stays clean for reading.

  1. In your GTM, click Preview.
  2. Paste the live page URL above and click Connect.
  3. Interact with the live page and watch your tags fire in Tag Assistant.

What you should expect to see

Moving your cursor to the very top edge adds a single exit_intent event in the timeline and dataLayer, firing your tag once.
0 of 15 lessons complete