Vibe Coding with Replit -- May 12, 2026

How to Add a Popup to My Replit Site That Captures Emails

By Arjita SethiMay 12, 20265 min read
Direct Answer

Add an email capture popup to your Replit site by asking Claude to build an exit-intent popup that triggers when the user moves their cursor toward the browser tab bar. The popup should appear once per session (controlled by sessionStorage) and once per 30 days per device (controlled by localStorage). It captures first name and email, submits to your existing form endpoint, and shows a success message. Total build time: 30-45 minutes.

Why Exit-Intent Popups Work

Exit-intent popups convert visitors who are about to leave without taking any action. These are visitors who have already engaged enough to read your content but have not converted yet. An exit-intent popup gives you one more opportunity to offer them something valuable before they leave.

The key to an effective popup: offer something specific and valuable, show it at the right moment (when leaving, not on arrival), and control frequency so it does not annoy repeat visitors.

The three frequency controls that matter: do not show on the same session twice (sessionStorage flag), do not show again for 30 days after dismissal (localStorage with expiry timestamp), and never show to someone who has already subscribed (check against the email field being pre-filled or against a localStorage flag set after submission).

The Popup Prompt for Claude

"Add an exit-intent email capture popup to my Replit site. The popup should: trigger when the user's cursor moves toward the top of the browser (exit intent), only show once per session and not again for 30 days after dismissal using localStorage, show a headline [your headline], a short description [your description], and a form with first name and email fields. On submission, POST to /api/subscribe and show a success message. Close the popup when the user clicks outside it or the X button. Add a class 'popup-shown' to localStorage to track whether it has been shown."

Frequently Asked Questions

How do I add an exit-intent popup to my Replit site?
Ask Claude to build an exit-intent popup that triggers on cursor movement toward the browser top, with localStorage frequency controls to show once per session and not again for 30 days.
What is exit intent detection?
A technique that detects when a user is about to leave the page by tracking cursor movement toward the browser tab bar or address bar. When the cursor moves in that direction, the popup triggers.
How do I prevent the popup from annoying repeat visitors?
Store a dismissed flag in localStorage with an expiry timestamp. Check it before showing the popup -- if the flag exists and has not expired, do not show. Reset after 30 days.
Should I show the popup immediately when visitors arrive?
No. Immediate popups have lower conversion rates and higher annoyance. Exit-intent (on leaving) or scroll-trigger (after 60% scroll depth) convert better and create a better user experience.
How do I track popup conversion rate?
Ask Claude to add a Google Analytics event that fires when the popup form is submitted successfully. Compare popup form submissions to total popup shows to calculate conversion rate.
Build With AI

Build Your Email Growth System

Channel 3 at Build with AI covers the complete email capture and nurture system.

Join Channel 3