Exit Intent Popup JavaScript for Webflow - A simple tutorial

Exit Intent Popup JavaScript for Webflow - A simple tutorial

Table of content

In today's digital landscape, retaining visitors and reducing bounce rates are paramount for website success. An exit-intent popup is a strategic tool that detects when a user is about to leave your site and presents a compelling message or offer to retain their attention.

This guide will walk you through the process of creating an effective exit-intent popup in Webflow, helping you boost conversions and enhance user engagement.

Today, I will show you how you can create a powerful exit intent popup javascript for any webflow website. In this exit intent popup tutorial you can simply copy and paste the JavaScript code into your Webflow website. This JavaScript can be used in any website be it WordPress, Wix, or any other static or dynamic website.

Let's learn step by step how to do webflow development and website platform development for exit intent popup.

Create Popup in your project

You can create a simple popup design in Webflow similar to below. I won't go into too much detail as I am assuming you already know how to create it in Webflow.

For those who are not using Webflow, you can create a popup in your platform or use HTML code below to create one.


<div class="exit-popup-modal">
<div class="exit-popup-wrapper">
<h2 class="heading">Heading</h2><a href="#" class="exit-popup-close">X</a>
<p class="paragraph ep-paragraph">Subheading</p>
<a href="#" class="exit-popup-btn">Book a Call</a>
</div>
</div>

All exit popup content will go inside the .exit-popup-modal container. It will have a black transparent overlay.
The .exit-popup-wrapper will have the actual content.

To make it work as a popup, you will also need some CSS.

Design your Exit Intent Popup For Webflow

You can design your popup in Webflow using CSS settings of each elements. Use your design sense to make your exit popup look prominent for your audience. So, let's explore the intricacies of Webflow modal popups and learn how to customize them to align with your brand.

For those, who are not using Webflow, you can use below CSS to design it. I am providing basic CSS to make it look like popup, you can use images or different colors to make it look good.


<style>
.exit-popup-modal {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    border-radius: 0;
    background-color: rgba(0,0,0,.7);
    text-align: left;
 }
 .exit-popup-wrapper {
    position: relative;
    top: 10%;
    bottom: 10%;
    display: block;
    width: 100%;
    max-width: 720px;
    margin-right: auto;
    margin-left: auto;
    padding: 40px;
    background-color: #f6f9ff;
}
</style>

As you can see, I've added a z-index to make sure it appears on top of every other elements on the page.

Write JavaScript to make Exit popup work

Now let's add a JavaScript and determine how to show the exit intent popup javascript.

We want to detect if the user moves their mouse cursor out of the window. And then we have to use cookie to determine that popup won't show all the time mouse cursor moves out of the window.

I have already written the whole exit intent JavaScript for you. You can simply copy and paste the JavaScript to your Webflow inside Custom Code section of Project Settings.

If you are using it on other platform, you can add this JavaScript in Footer section of your website. And please make sure that jQuery library is added to the site.



<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
<script>
/*cookie function - Set and read cookie */
  function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/* Detecting mouse out event */
  document.addEventListener("DOMContentLoaded", () => {
  document.addEventListener("mouseout", (event) => {
    if (!event.toElement && !event.relatedTarget) {
      setTimeout(() => {
        var ifcookie = readCookie("exitpopup");
    	if(ifcookie !="hide"){
      		$('.exit-popup-modal').fadeIn();
    	}
      }, 100);
    }
  });
});
/* Closing the popup and setting up cookie so it won't show it again.*/
$('.exit-popup-close').on('click', function(){
  createCookie("exitpopup","hide","7"); //You can set any number of days here.
   $('.exit-popup-modal').fadeOut();
});
</script>

So, that's webflow exit intent popup.
You have your exit intent popup ready using Javascript.

Also, Read: Strategies For Improve Website User Experience

Why Use an Exit-Intent Popup?

Exit-intent popups are an effective marketing tool that helps businesses retain visitors and convert them before they leave. Here’s why they work:

  • Reduce Bounce Rates: By offering a discount, freebie, or valuable content, you can convince users to stay.
  • Increase Conversions: Strategic exit popups can turn abandoning visitors into subscribers or customers.
  • Recover Lost Sales: E-commerce stores use exit popups to remind users about their cart or offer a last-minute discount.
  • Grow Email Lists: Many businesses use exit popups to collect emails for future marketing campaigns.
Example: Imagine a user browsing your Webflow store, hesitating to buy. Just as they move to exit, a popup offers 10% off their first purchase—this small nudge can lead to conversion!

Best Practices for Designing an Exit-Intent Popup

Not all exit popups are effective. Follow these best practices to create a high-converting popup:

  1. Make the Offer Irresistible
    • Offer something valuable: discounts, free guides, exclusive deals, or free trials.
    • Use a clear call-to-action (e.g., “Get 10% Off Now” instead of “Submit”).
  2. Keep It Simple & Non-Intrusive
    • Avoid long forms—ask for just an email or phone number.
    • Use minimal text with a strong headline & CTA button.
  3. Match the Popup Design with Your Brand
    • Use your brand colors and fonts to make the popup feel natural instead of intrusive.
  4. Create a Sense of Urgency
    • Use words like “Limited Time Offer”, “Only for the Next 5 Minutes”, or “Expires Soon”.
  5. Mobile-Friendly Optimization
    • Ensure the popup looks good on mobile devices and doesn’t block important content.

Final Words

Now you know how to create step by step exit intent popup. Few things you must remember to make it more effective for your users.

Here's a simple checklist to get the most out of your exit intent popup.

  • Keep a meaning message so your user will stay interested.
  • Create urgency if possible.
  • Give something for free and grab an email Id.
  • Focus on user experience and catchy design to make them stay.

By following this comprehensive guide, you've successfully implemented an effective exit-intent popup in Webflow using JavaScript. This strategic addition is poised to reduce bounce rates and enhance user engagement on your website. Remember to monitor the performance of your popup and make adjustments as needed to optimize its effectiveness.

Happy coding!

Also, Read: Top 10 Best Webflow Apps & Integrations for your site
Recommended To Read: Complete Webflow Guide

FAQs

1) What is an exit intent popup, and how does it engage website visitors?

An exit intent popup is a strategic element that appears when a user is about to leave a website. It captures attention and can present offers, encouraging visitors to stay longer or take specific actions.

2) What is the best way to design an exit-intent popup?

Use minimal text, a strong call-to-action, and an irresistible offer. Keep it mobile-friendly and match your brand’s design.

3) Why is an exit intent popup beneficial for website conversion, and what are its primary advantages?

Exit intent popups can significantly reduce bounce rates by re-engaging visitors before they leave. They offer an opportunity to present special offers, collect email addresses, or provide relevant information, ultimately boosting conversions.

4) Do exit popups affect SEO?

No, as long as they don’t block content immediately. Google penalizes intrusive interstitials, but exit popups are not affected since they trigger on exit.

5) How can I implement exit intent popups on my Webflow site using JavaScript, and is it a complex process?

Implementing exit intent popups on a Webflow site involves adding custom JavaScript code. While it may seem technical, the process is explained in the blog post and can be achieved with step-by-step instructions.

6) Can I track how well my exit popup is performing?

Yes! You can track conversion rates using Google Analytics, Webflow Analytics, or tools like Hotjar to see how users interact with your popup.

7) Can I create exit popups in Webflow without JavaScript?

Yes, but you’ll need third-party tools like OptinMonster or ConvertFlow. Using JavaScript gives you more control and flexibility.

8) Do exit intent popups work well on mobile devices, and what considerations should I keep in mind for a mobile-friendly experience?

Exit intent popups can be optimized for mobile devices. The blog post likely provides guidance on ensuring a responsive design, allowing users on smartphones and tablets to have a positive interaction with the exit intent popup.

9) How can I customize the appearance of the exit-intent popup?

Use Webflow Designer for styling, add custom CSS for design tweaks, and apply Webflow interactions for animations. JavaScript can further enhance customization.

10) Is it possible to trigger different popups based on specific user behaviors?

Yes, by detecting page URLs, tracking mouse movements, using cookies, or segmenting users based on referral sources and activity.

Viken Patel

Viken Patel

Viken Patel has 14+ years of experience working with websites. He is passionate about building website that converts. His marketing background helps him build the sales driven websites.

Importance Of Webflow Maintenance for Sustaining Site Health

Importance Of Webflow Maintenance for Sustaining Site Health

Slow pages, SEO drops, and security risks? Learn how regular Webflow maintenance prevents these common website issues.

How to Create an XML Sitemap in Webflow (Step-by-Step)

How to Create an XML Sitemap in Webflow (Step-by-Step)

Want better Google rankings for your Webflow site? Learn how to generate, optimize, and submit your XML sitemap in just a few simple steps.

Why Open Graph Matters: A Webflow Developer’s Perspective

Why Open Graph Matters: A Webflow Developer’s Perspective

Learn what Open Graph is, why it matters, and how to implement it to create compelling social media link previews that drive clicks.

Partner with a Webflow Agency for your Webflow website.

Quick Turnaround. No Contracts. Cancel Anytime. Book a 30 minutes consulting call with our expert.