
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.
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.
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:
- Create a custom HTML tag and paste Optinator’s Javascript code.
- In Triggering section choose “Custom – exit-intent” (that’s a trigger that was included in my Google Tag Manager Recipe).
- 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!
8 COMMENTS
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.)
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.
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).
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.
Hi Julius,
Thanks for the receipe. Does this also work on android and ios ?
Thanks
Hemang
Unfortunately, no.
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.
I don't think that's possible.