• Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login
  • Courses
    • Courses
    • Course bundles
  • Blog
  • Services
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • About
    • About
    • Contact
  • Login

March 14, 2017

Catch Exit-intent with Google Tag Manager

The term exit intent has been growing in popularity over the last years. Essentially, it uses Javascript and the web browser to track the movements of a user so a special offer or opt-in form can be displayed when they show signs of leaving your website. In this blog post I’ll show you how to track exit-intent with Google Tag Manager.

Although most of lead generation solutions (like OptinMonster, Sumo, etc.) offer exit-intent option by default, some of you might want to fire a custom form upon user’s exit.

And the good news is that you can easily achieve that with Google Tag Manager and my ready-made recipe.

DOWNLOAD EXIT-INTENT TRACKING RECIPE FOR GTM

How does this solution work?

First, you’ll need to download this Google Tag Manager Recipe and import to your GTM container (make sure you follow the instructions).

It will automatically create a custom auto-event listener which monitors visitors’ behavior on you website. Once their mouse cursor leaves website’s window the listener will create a trigger called exit_intent.

exit-intent trigger in google tag manager

In most cases mouse cursor leaves the window when a visitor intends to close the tab or browser. That’s an opportunity to shoot a special offer (e.g. a discount)!

 

 

Ok, So What’s Next?

Now you can use that trigger and assign it to any tag in Google Tag Manager.

Since I don’t have any actual example here, I’ll pretend I am using a made-up lead generation tool called “Optinator”. It has some awesome features but for some reason “Exit-intent” feature is absent.

In order to work, Optinator requires to add its Javascript code to my website – on all pages. If I add the script on all pages, the popup will appear immediately after the visitor lands on a page. And that’s not what we want, right?

But it’s not a problem because I can set the rule in Google Tag Manager to fire Optinator’s script only when the visitor tries to leave the website. My following steps are:

  1. Create a custom HTML tag and paste Optinator’s Javascript code.
    Optinator
  2. In Triggering section choose “Custom – exit-intent” (that’s a trigger that was included in my Google Tag Manager Recipe).
  3. Hit Save.

Now my popup will appear only when user’s mouse cursor hovers away from website’s window.

 

Conclusion

In Google Tag Manager, implementing an exit intent trigger is fairly simple via a custom HTML tag. Download the ready-made solution I have published in this huge library of Google Tag Manager Recipes and import to your GTM container.

The recipe will add a listener which tracks visitors’ intentions to leave the website and creates trigger. Assign that trigger to any tag in Google Tag Manager and you’re good to go!

Julius Fedorovicius
In Google Tag Manager Recipes Google Tag Manager Tips
8 COMMENTS
Jesse
  • Jan 2 2019
  • Reply

Thank you Julius. Is there a way to restrict a tag using the exit intent to only trigger once per "xx" minutes? (It seems this currently triggers indefinitely if the user's cursor goes back and forth between the URL bar and page content.)

    Julius Fedorovicius
    • Jan 2 2019
    • Reply

    Yes, it is possible. You'll need to employ cookies. Whenever an exit-intent event fires, you need to create a cookie that is valid for 15 minutes. If the cookie is still present (meaning that the 1st party cookie contains any value), then your exit-intent listener should not fire. Every time a page loads, you need to check whether the cookie is present. If it isn't, fire the exit-intent listener once again.

Alessandro Sandini
  • Mar 14 2019
  • Reply

Hello Julius, so I tried to install Optinmonster with GTM but I think I've done something wrong.
I have a website which is both in Italian and English language.

So I created this trigger and tag --> https://www.dropbox.com/s/tlk5l502oq0rtwv/screenshot.pdf?dl=0

Can you tell me what you think I have done wrong?

I can make it work only if I selected, on my trigger, all pages views (but doesn't work for me because the exit pop-pop pops up - sorry about that - on the english pages as well).

    Julius Fedorovicius
    • Mar 16 2019
    • Reply

    Hey, if you add multiple conditions to a trigger, ALL of them must be met. If you want a tag to fire on one of two conditions, you need to either create two separate triggers for each URL or you need to use regular expressions in your trigger.

Hemang Pandit
  • Jul 21 2019
  • Reply

Hi Julius,

Thanks for the receipe. Does this also work on android and ios ?

Thanks
Hemang

    Julius Fedorovicius
    • Jul 21 2019
    • Reply

    Unfortunately, no.

Cyriac Joseph
  • Apr 21 2020
  • Reply

Hi Julius,

Thank you for this great recipe wondering if there is a way to make the trigger more sensitive so it triggers earlier than now. I feel like by the time the tag fires the user has already closed the window.

    Julius Fedorovicius
    • Apr 22 2020
    • Reply

    I don't think that's possible.

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • How to Track Gravity Forms With Google Tag Manager: Complete Guide
  • Introduction to Google Tag Manager Server-side Tagging
  • 3 Ways to Pull Data from Data Layer with Google Tag Manager
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings