Dynamic Exit Intent Popup
Built a custom Shopify exit intent popup that shows promotional messaging when a visitor is about to leave the website.
Showing a Message Before Visitors Leave
Some visitors leave the website without completing their purchase. I needed a simple way to show a promotional message before they left the page.
The Challenge
The website needed an exit intent message that could appear when a visitor was about to leave. The message also needed to be flexible so the promotional content could be changed when needed.
The Solution
I built a custom popup using HTML, CSS, JavaScript, and Shopify Liquid. JavaScript detects the visitor's exit movement and opens the popup with the promotional message.
How It Was Built
The popup was created directly in the Shopify theme so the content and behavior could be controlled with custom code.
- Created the popup structure using HTML.
- Added custom CSS for the popup design and responsive layout.
- Used JavaScript to detect exit intent.
- Added dynamic promotional content using Shopify Liquid.
- Added close and interaction controls for the popup.
Tools & Technologies
Popup Flow
The popup only appears when the exit condition is detected.
Exit Intent JavaScript
The JavaScript listens for the visitor's mouse movement and opens the popup when the cursor moves toward the top of the page.
const popup = document.getElementById("exitPopup");
const closePopup = document.getElementById("closePopup");
let popupShown = false;
document.addEventListener("mouseleave", function(event) {
if (event.clientY <= 0 && !popupShown) {
popupShown = true;
popup.classList.add("show");
}
});
closePopup.addEventListener("click", function() {
popup.classList.remove("show");
});
This is a simplified version of the exit intent logic used in the project. The popup content and styling can be changed depending on the campaign.
More Control Over Exit Messaging
The custom popup gave the website a simple way to show a promotional message when a visitor was about to leave.
Because the popup was built with Shopify Liquid and custom JavaScript, the content and behavior could be changed without rebuilding the whole section.
What This Project Demonstrates
Shopify
Working directly with a Shopify theme to add custom functionality.
JavaScript
Using JavaScript to detect user actions and control popup behavior.
Liquid
Using Shopify Liquid to display dynamic campaign content.
UX
Creating a simple message to engage visitors before they leave the website.
More Shopify Projects
Explore more of my Shopify development, CRO, Klaviyo, and custom-code projects.
← Back to Projects