Lesson 14 of 15
Exit Intent
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
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.
Build it in GTM
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.
- Go to Tags → New and choose Custom HTML.
- Paste a script that adds a
mousemovelistener and pushes{ event: 'exit_intent' }whene.clientY <= 10, firing only once. - Set its firing trigger to All Pages, name it
Listener - Exit intent, and Save.
Create the Custom Event trigger
- Go to Triggers → New and choose Custom Event.
- Set Event name to
exit_intent(it must match theeventyou pushed). - Name it
Event - exit_intentand Save.
Attach a tag
- Go to Tags → New and choose your save-offer modal tag, or a Custom HTML test tag with
<script></script>. - Under Triggering, add
Event - exit_intent, then Save.
- Go to Tags → New and choose your save-offer modal tag, or a Custom HTML test tag with
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.
- In your GTM, click Preview.
- Paste the live page URL above and click Connect.
- Interact with the live page and watch your tags fire in Tag Assistant.
What you should expect to see
exit_intent event in the timeline and dataLayer, firing your tag once.