To add a popup to a website, paste one script tag from a popup tool just before the closing body tag of your site’s shared layout, confirm it loads, then build the popup and choose its trigger, its pages and how often it shows. The same steps work on a hand-built site, a static site generator, WordPress or a site builder that accepts custom code. The tag is the easy part. The settings that decide when the popup appears are what make it useful rather than annoying.

Key takeaways

  • Paste the script tag once, in the layout or footer every page shares, rather than page by page.
  • Check that the tag loads on the live address in a private window before you troubleshoot the popup itself.
  • Start with one goal per popup, such as an email signup or a link to a page, and a calm trigger like a short timer or a scroll depth.
  • Use URL rules to keep the popup on the pages where it helps, and frequency settings so a visitor who closed it is not asked again on every page.

How a script-tag popup works

A script-tag popup is a small piece of JavaScript your pages load from the popup tool’s server. When a page opens, the script fetches your active popups, watches for the trigger you chose, and draws the popup on top of the page. The design, the copy, the triggers and the collected emails all live in the popup tool, so you change a popup without touching your site again.

This has two consequences worth knowing before you start. First, any site that can load a script can show popups, whatever it is built with. Second, the popup only knows what the page and the browser can tell it: which address the visitor is on, how far they scrolled, whether the mouse left the window. It does not know what is in a shopping cart unless your site tells it.

Step 1: decide what the popup is for

Pick one job per popup before you open any tool, because the job decides the format and the trigger.

  • Collect emails for a newsletter, a waitlist or a lead magnet. Use a centered popup with a single email field.
  • Point to a page, such as a new product, a launch, or a pricing page. Use a popup or a bar with one clear button.
  • Announce something sitewide, such as holiday hours or a sale. Use a bar along the top or bottom of the page, which leaves the page clickable.

If you have two jobs, build two popups and give them different pages, rather than one popup that asks for everything.

Step 2: create the popup account and register your address

The popup tool ties your script tag to your site’s address, so register the address visitors actually use. In PopupGenius, for on-brand upsell and email popups on your website, you enter your site’s address on the Site page, save it, and copy the script tag shown there. It is added with one script tag before the closing body tag, and the free plan needs no card. Saving the address also reads your home page’s colors and fonts for the popup’s design.

Two address details trip people up. The www and non-www versions of a domain count as the same site, but another subdomain, a staging address, or http instead of https counts as a different one. Test on the live address you registered.

Step 3: paste the script tag before the closing body tag

Put the tag in the one place every page shares, just before the closing body tag. The tag looks like this, with your own key:

<script async src="https://cdn.popupgenius.app/p/YOUR-SITE-KEY.js"></script>

Where that shared place is depends on how the site is built:

  • Hand-written HTML. If every page is its own file, paste the tag into each one, or better, move the footer into an include your server or build step adds to every page.
  • A static site generator or a framework. Add the tag to the base layout or the root document template, so every generated page carries it.
  • WordPress. Use a footer scripts field in your theme’s settings, a Custom HTML block in a block theme’s footer, or a child theme. The guide to adding a WordPress popup without a plugin covers all three.
  • Site builders. Wix, Squarespace and Webflow each have a site-wide custom code or code injection setting with a footer area. Some of them only allow custom code on certain paid plans, so check yours before you plan around it.

The async attribute matters: it lets the browser keep building the page while the script downloads, so the popup never holds up your content.

Step 4: check that it loads

A popup that never appears is usually a tag that is not on the page. Check in this order.

  1. Publish or deploy. Site builders and static hosts often need a publish step before changes go live.
  2. Clear caches. A CDN or page cache can serve the old page for a while.
  3. Open a private window on the live address and view the page source. Search for the tag near the bottom.
  4. Look at the tool’s status. On the PopupGenius Site page, the status line changes to “Installed” once a browser on your site has loaded the script, which confirms the tag before you look at any popup setting.

If the tag is on the page and nothing opens, the cause is the popup’s settings: it is not switched on yet, its trigger has not fired, or its page rules leave out the page you are on.

Step 5: build the popup and choose its trigger

Start from a template close to your goal and change the copy, rather than designing from a blank box. Then choose what opens it.

  • Timer. Opens a set number of seconds after the page starts loading. Simple and works on every device; a delay of several seconds is a fair starting point to test.
  • Scroll depth. Opens once the visitor has scrolled part of the page. Good on long articles and landing pages, where scrolling shows interest.
  • Exit intent. Opens when the mouse leaves the window through the top, so it works on desktop only. Pair it with a timer or scroll trigger to reach phones. The exit-intent popup guide explains what that signal can and cannot tell you.
  • Your own code. Opens when your site fires an event, for example after a calculator finishes or a video ends.

Several triggers can be on at once; the first one that happens opens the popup. For more on how long to wait before showing anything, the email popup timing guide applies to any site.

Step 6: limit the pages and the frequency

Targeting and frequency are what separate a helpful popup from one visitors resent.

Pages. Use URL rules to show the popup only on paths that match, such as everything starting with /blog/, or to show it everywhere except some pages, such as your contact page or a checkout. Rules compare the part of the address after your domain.

Frequency. Choose between every time, once per visit, or once every set number of days. Once per visit is a sensible first test for most popups. A teaser bubble that waits for a click is a gentler way to keep an offer visible to returning visitors.

Devices. If the popup is large, consider a separate, smaller version for phones, or show the large one on desktop only.

Optional: open the popup from your own code

If your site has its own JavaScript, you can open a popup at exactly the right moment instead of guessing with a timer. With the Custom JS trigger switched on and an event name set, PopupGenius opens the popup when your page fires that event:

window.dispatchEvent(new CustomEvent("calculator:done"));

Your code can also call window.PopupGenius.show(), which is available once the script has started after the page loads. Frequency settings still apply, so a visitor who declined is not asked again just because the event fired twice.

How to tell it worked

Open the live site in a private window, do what a visitor would do, and watch the popup open at the moment you planned. Then check it on a phone, close it, and make sure it stays closed on the next page. After a few days, compare how many times the popup was shown with how many signups or clicks it produced: if it is shown often and rarely used, change the offer or the wording before the trigger.

FAQ

Do I need to know how to code to add a popup to my website?

No. You need to paste one line into the footer of your site, which most site builders and content management systems allow through a custom code setting. Everything else, from the design to the trigger, is set in the popup tool. Coding only helps if you want to open the popup from your own events.

Will a popup script slow my website down?

A tag with the async attribute does not block the page from rendering, and a well-built popup script waits until the page has loaded before it does its work. Run your usual speed test before and after adding it to see the difference on your own pages.

Can I show a popup on only one page?

Yes. Use a URL rule that matches that page’s path exactly, or one that matches the start of a group of paths. The script tag still loads everywhere, but the popup only opens where the rule matches.