This WordPress free plugin helped “User Email Collector” that displays a popup to collect visitor emails using an exit-intent trigger (when the user attempts to leave the page). The plugin is designed for non-coders, with a settings page to customize the popup message, button text, and styling. It integrates with WordPress to store emails in a custom database table, supports Contact Form 7-style form fields, and includes an admin interface to view collected emails. The popup uses JavaScript for exit-intent detection and is lightweight, secure, and compatible with modern browsers.
📥 My Awesome Plugin
This plugin helps you automate tasks and improve web performance.
⬇️ Download Plugin ZIP💌 Subscribe to Updates
Installation and Setup Instructions
- Download the Plugin:
- Copy the PHP code above into a file named wp-user-email-collector.php.
- Place this file in a folder named wp-user-email-collector.
- Upload to WordPress:
- Zip the wp-user-email-collector folder.
- In the WordPress admin dashboard, go to Plugins > Add New > Upload Plugin.
- Upload the zipped folder and click Install Now.
- Activate the Plugin:
- After installation, click Activate Plugin.
- The plugin will create a database table to store emails and generate JavaScript/CSS files for the popup.
- Configure Popup Settings:
- In the WordPress admin dashboard, go to the new menu item Email Collector.
- Configure the following:
- Enable Popup: Check to enable the exit-intent popup (default: enabled).
- Popup Message: Customize the popup content using the WordPress editor (default: a subscription prompt).
- Button Text: Set the submit button text (default: “Subscribe”).
- Click Save Changes.
- Test the Popup:
- Visit your site’s front-end in a browser.
- Move your mouse cursor toward the top of the browser window (simulating leaving the page) to trigger the popup.
- Enter an email address and submit the form.
- Check for the success message and verify the email appears in the View Emails submenu.
- View Collected Emails:
- Go to Email Collector > View Emails to see a table of collected emails with timestamps.
- Use a database tool or export plugin (e.g., WP All Export) to download emails as a CSV if needed.
Features
- Exit-Intent Popup: Displays a popup when users attempt to leave the page, detected via mouse movement.
- Email Collection: Stores submitted emails in a custom WordPress database table with timestamps.
- Customizable Popup: Edit the popup message and button text via a WYSIWYG editor.
- Responsive Design: Popup is mobile-friendly with basic CSS styling.
- Admin Interface: View collected emails in a table under the View Emails submenu.
- Session Control: Popup shows only once per browser session to avoid annoyance.
- Single File: Core functionality in one PHP file, with generated JS/CSS files on activation.
- Secure: Uses AJAX with nonces, sanitizes inputs, and prevents duplicate emails.
How It Works
- On activation, the plugin creates a database table (wp_uec_emails) to store emails and generates uec-popup.js and uec-popup.css files.
- It enqueues the JavaScript and CSS on the front-end, using jQuery for popup functionality.
- The JavaScript detects exit-intent by monitoring mouse movement (mouseleave event) and shows the popup once per session (stored in sessionStorage).
- The popup form submits emails via AJAX to a secure endpoint, validated with a nonce.
- Emails are stored in the database, with checks to prevent duplicates.
- The admin interface displays all collected emails in a table, ordered by submission date.
Notes
- Exit-Intent Limitations: Exit-intent detection relies on mouse movement and may not work on some mobile devices or touch-based browsers due to lack of mouse events. Consider adding a delay-based trigger for mobile if needed.
- GDPR Compliance: If targeting EU users, add a consent notice to the popup message (e.g., “By subscribing, you agree to our privacy policy”) and link to your privacy policy. Consult a legal expert for compliance.
- Performance: The popup is lightweight (~2 KB JS/CSS), with minimal impact on page load. AJAX requests occur only on form submission.
- Compatibility: Works with WordPress 5.0+ and modern browsers. Test with themes/plugins that modify front-end scripts (e.g., page builders) for conflicts.
- Security: Emails are sanitized, and AJAX requests are protected by nonces. The database table uses a unique key to prevent duplicate entries.
- Data Export: Use a plugin like WP All Export or a database tool (e.g., phpMyAdmin) to export emails. I can provide a CSV export feature if needed.
- Webloop Integration: Based on your interest in automation and services like those offered by Webloop (e.g., business automation, web development), this plugin can be branded for Webloop clients to build email lists for marketing campaigns, potentially integrating with Webloop’s AI tools for personalized follow-ups.
Troubleshooting
- Popup Not Showing: Check if Enable Popup is checked. Test in a desktop browser by moving the mouse to the top of the window. Clear browser session storage (sessionStorage.clear() in console) to reset the popup. Ensure jQuery is loaded (most themes include it).
- Emails Not Saving: Enable debugging (define(‘WP_DEBUG’, true); in wp-config.php) and check wp-content/debug.log for database or AJAX errors. Verify the database table (wp_uec_emails) exists in phpMyAdmin.
- Mobile Issues: Exit-intent may not trigger on mobile. Test on a desktop first, or request a mobile-specific trigger (e.g., scroll-based or time-delayed popup).
- Styling Conflicts: If the popup looks broken, check for theme CSS overrides. Modify uec-popup.css in the plugin directory or request custom styles.
- AJAX Errors: Ensure your site uses HTTPS and the AJAX URL (admin-ajax.php) is accessible. Check the browser console for errors.
This plugin is ready to use and provides an effective way to collect visitor emails with an exit-intent popup, ideal for building mailing lists. Let me know if you need additional features (e.g., CSV export, custom popup designs, integration with mail services like Mailchimp, or Webloop-specific branding) or help with setup!