How to create targeted popups on WordPress
You can create a basic targeted popup with WordPress markup, CSS and JavaScript, but page rules, exit intent, scheduling, frequency limits and email forms quickly become custom development. For most campaigns, use a popup builder after deciding exactly who should see the message and when.
- 01Define the audience and offer
- 02Choose the popup type
- 03Build the manual version
- 04Add targeting and frequency rules
- 05Make the dialog accessible
- 06Test delivery and conversion
- 07Use a builder for the fast way
What you need
- A WordPress site with administrator access
- A clear offer, message or email form
- An email marketing account if the popup collects leads
- A child theme or site-specific plugin for custom code
Define the audience and offer
Choose one audience and one action before you build anything. Examples include visitors reading a particular category, first-time visitors, WooCommerce shoppers with items in their cart, or people arriving from a campaign link.
Write down the display rule, trigger, frequency limit and exclusions. For example: show a newsletter offer on blog posts after 45 seconds, once per visitor, but not to logged-in users or existing subscribers.
Choose the popup type
Use a modal for a short, important action such as an email signup or coupon. A slide-in or notification bar is less disruptive for reminders and content upgrades. Avoid showing several popups at once, especially on mobile.
Include a clear close button, a useful heading and a short explanation of what happens after the visitor submits the form. If you collect personal data, add the privacy information required for your audience and email service.
Build the manual version
A basic popup can be built without a plugin. Add the popup markup through a child theme template or a site-specific plugin, hide it with CSS, and use JavaScript to open and close it after a page-load, time, click or scroll event. WordPress recommends enqueueing JavaScript rather than inserting scripts directly into page content.
For page targeting, render the markup only where it is needed by using WordPress conditional tags such as is_page(), is_single() or is_singular(). Do not evaluate those conditions too early in a file that loads before the main query; WordPress documents that timing as a common error.
Add targeting and frequency rules
Connect the audience rule to the trigger. A simple implementation can check the current page on the server and use a cookie or browser storage value to avoid showing the popup again after dismissal or submission. Add a date check if the campaign must start or end at a particular time.
Exit intent is mainly a desktop interaction and is unreliable on touch devices. Use a delay or scroll-depth trigger for mobile instead. Also test logged-in users, cached pages, private browsing and visitors who arrive through campaign links, because caching can serve the same popup markup to the wrong audience.
Make the dialog accessible
Give the popup a meaningful title, a labelled close button and dialog semantics. When it opens, move focus into it; when it closes, return focus to the element that opened it. Support the Escape key and keep keyboard focus inside a true modal without creating a keyboard trap. These are part of the expected accessible dialog behaviour described by W3C guidance.
Check the popup with a keyboard and screen reader, then check it at narrow widths. A frequent Friday-afternoon failure is a close control that works with a mouse but cannot be reached or activated from the keyboard.
Test delivery and conversion
Test every targeting combination in an incognito window: included pages, excluded pages, desktop, mobile, returning visitors, logged-in users and visitors who have already submitted the form. Confirm that the form sends the expected confirmation and that the popup does not reappear immediately after submission.
Check the browser console if the trigger fails or the close button does nothing. WordPress notes that browser developer tools are useful for diagnosing JavaScript errors, which can stop other interactive features on the page as well.
Use a builder for the fast way
For campaigns that need page targeting, behaviour triggers, schedules, animations, responsive layouts and email integrations, use JetPopup For Elementor instead of maintaining the markup, CSS and JavaScript yourself. Create the popup in Elementor, choose its display conditions, set the trigger and frequency rules, connect the form and preview it on desktop and mobile.
This route is usually the practical choice when marketing staff need to change offers without editing theme files. Keep the manual route for one small, stable notice where adding a plugin would create more administration than value.
Let JetPopup For Elementor do it
Elementor-based popup builder with behavior targeting, scheduling, animations, and email integrations for conversion-focused campaigns.
Sources
- developer.wordpress.org /themes/core-concepts/including-assets/?utm_source=openai
- developer.wordpress.org /themes/classic-themes/basics/conditional-tags/?utm_source=o…
- w3.org /WAI/WCAG21/Understanding/no-keyboard-trap?utm_source=openai
- developer.wordpress.org /advanced-administration/debug/debug-javascript/?utm_source=…
Questions
- Can I create a targeted popup without a plugin?
- Yes, you can create a basic targeted popup with WordPress markup, CSS and JavaScript. Use conditional tags to decide which pages receive the markup, then add JavaScript for the trigger and a cookie or browser storage value for frequency control. Exit intent, scheduling, accessibility and email integrations make the custom version considerably more work.
- How do I show a popup only on selected WordPress pages?
- Show the popup markup only when the current request matches your rule. WordPress conditional tags such as <code>is_page()</code>, <code>is_single()</code> and <code>is_singular()</code> can target pages, posts or post types, but they must run after WordPress has established the main query. A popup builder can provide the same rules through display conditions.
- What is the best trigger for mobile visitors?
- A timed or scroll-depth trigger is usually more dependable on mobile than desktop exit intent. Touch devices do not provide the same reliable cursor movement used to detect a visitor leaving through the top of the browser window. Keep the popup small, delay it until the visitor has engaged, and test it on real phones rather than relying only on a desktop emulator.
- Why does my popup appear on every page or to the wrong visitors?
- Caching, broad targeting conditions, duplicated scripts and an incorrectly scoped cookie are common causes. Purge page and CDN caches after changing rules, inspect the page source on an included and excluded URL, and check that the frequency value is stored under a unique name. Also exclude logged-in users and completed subscribers when those groups should not see the campaign.
- How do I stop a popup from causing accessibility problems?
- Make the popup a properly labelled dialog with a keyboard-accessible close button, visible focus, Escape-key support and managed focus. Focus should move into the dialog when it opens and return to the original control when it closes. Do not leave keyboard users behind the overlay or create a trap they cannot escape.