Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Injected popups and malvertising on your site: find and fix

OPS-147Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Malvertising means malicious or unwanted advertising code. On your own site it usually shows up as a popup, fake virus alert, full-screen ad, new tab or redirect that you did not build. The code is injected: someone or something added a script to your pages.

Common sources are a hacked plugin or theme, a stolen admin login, an edited tag in Google Tag Manager, a compromised third-party widget (chat, review or analytics script), or an ad network script that was swapped for a bad one. Because the code is often loaded from another domain, your own files may look clean.

Why it costs you leads or sales

A popup that covers your form or checkout button blocks the action you want. A redirect sends paying traffic to someone else's page. Fake alerts make visitors distrust you and leave. Browsers and Google may also flag the site, which stops visitors before they see it.

These popups are often shown only to some people: first-time visitors, mobile users or visitors from ads or search. That means you can browse your own site for weeks and see nothing while customers do.

How an injected popup breaks the funnel
  1. Ad clickVisitor lands on your page
  2. Injected popupRogue script opens an overlay or redirect
  3. Form or checkoutCovered or never reached
  4. Lead or saleNot recorded

The rogue script runs on the landing page and the visitor never reaches the form.

A popup covers the button

An overlay you did not add sits on top of your call to action.

How to check if your site has it

Find the script that is causing it
  1. Test like a new visitor

    Open the page in a private window, on a phone using mobile data, and by clicking through from a Google search or an ad. Clear cookies first. Disable your own extensions or use a fresh browser profile.

  2. List every script the page loads

    Open DevTools (F12), go to the Network tab, tick Disable cache, reload and filter by JS. Look for domains you do not recognise, random-looking names or recently added files.

  3. Find who started the popup

    In DevTools, right-click the popup and choose Inspect. Note its class or id and any iframe source. In the Network tab, the Initiator column shows which script loaded each request.

  4. Check the page source

    View source and search for <script src=, eval(, atob(, document.write, window.open and long encoded strings.

  5. Review your tag manager and site settings

    Check Google Tag Manager for Custom HTML tags you did not create, and your site's header and footer code injection fields. Check the version history for recent changes.

Search WordPress files for common injection patterns (SSH)bash
cd /path/to/wordpress
grep -rIl --include=*.php --include=*.js -E "eval\(base64_decode|atob\(|document\.write\(unescape" wp-content | head -50

How to fix it

Fix in this order: contain, remove, close the hole. If the popup came from a hack rather than a bad third-party tag, removing only the visible script is not enough.

Remove the injected code by platform
  1. Back up, then scan

    Take a full backup. Run a malware scanner plugin from a reputable vendor and compare core, plugin and theme files with clean copies.

  2. Reinstall core, plugins and theme

    In Dashboard > Updates, reinstall WordPress. Delete and reinstall each plugin and the theme from the official source. Remove plugins you do not use.

  3. Check the database

    Look in Settings or your theme's header and footer script fields, and in widgets, for unknown script tags. Check Users for admins you did not create.

  4. Rotate credentials

    Change all admin, hosting, FTP/SFTP and database passwords, and regenerate the salts in wp-config.php.

Close the hole so it does not return
  1. Update everything

    Update the CMS, plugins, themes and apps. Remove abandoned ones.

  2. Change passwords and turn on two-step login

    Do this for every admin, the host, the tag manager and the domain registrar.

  3. Remove unknown users and API keys

    A hidden admin lets the attacker come back.

  4. Replace untrusted third-party scripts

    If the script came from a vendor, contact them and remove or replace the widget.

  5. Ask for a review if flagged

    If a browser or Google warning appeared, request a review once the site is clean.

Before and after cleanup

Compromised

  • Unknown script loads from another domain
  • Popup or redirect appears for some visitors
  • Unknown admin or tag exists
  • Plugins out of date

Clean

  • Only scripts you recognise load
  • No popup on any device or referrer
  • Users and tags reviewed
  • Software updated, two-step login on

How to confirm it's fixed

Confirmation checklist
  • Private window, desktop: no popup or redirect
  • Phone on mobile data: no popup or redirect
  • Arriving from a Google result and from a test ad link: no popup
  • DevTools Network tab shows no unknown domains
  • Form submits and checkout button is clickable
  • Tag manager and code injection fields contain only known code
  • Repeat the checks the next day, since some injections come back

How to prevent it happening again

Prevention
  • Keep software updated and remove unused plugins and apps
  • Use unique passwords and two-step login for every account
  • Give people the lowest access level they need
  • Keep a list of approved third-party scripts and review it each quarter
  • Keep file backups and use version control for custom code
  • Set a Content Security Policy that limits which domains can load scripts, if your setup allows it
  • Re-run your key journeys on a schedule, not only after changes
Example Content Security Policy header value (test in report-only mode first)html
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' https://www.googletagmanager.com https://www.google-analytics.com; report-to csp-endpoint

How FunnelGuard handles this

FunnelGuard detects this only partly. It runs your real customer journeys on a schedule with a robot visitor, so if an injected popup or redirect stops a step from working, for example it covers a button or sends the robot off the page, that step fails. A failure is re-checked from a second region and you get one alert with a screenshot and a likely cause.

Questions people ask

Why is my website showing popups I didn't add?

Most often a script on your site is loading them. It may come from a hacked plugin or theme, an edited tag in your tag manager, or a compromised third-party widget. Open DevTools, check the Network tab for unknown domains, and review your tag manager and code injection fields.

How do I find the script causing popups on my site?

Open DevTools (F12), go to the Network tab, reload and filter by JS. Look for domains you do not recognise and check the Initiator column to see what loaded them. Also search the page source for terms like eval, atob and window.open.

Why do the popups only show for some visitors and not me?

Injected code often targets first-time visitors, mobile users or people arriving from search or ads, and hides from logged-in admins. Test in a private window, on a phone using mobile data, and by clicking through from a Google result.

Is a popup on my site always a hack?

No. It can also come from a legitimate third-party script that was changed, an ad network you use, or a browser extension on one visitor's device. If several people on different devices see it, the cause is on your site and you should treat it as a possible compromise.

How do I remove malvertising from my WordPress site?

Back up the site, scan it, reinstall WordPress core, plugins and the theme from official sources, and check the database and header or footer script fields for unknown code. Then change all passwords, remove unknown admin users and update everything.

Can a Google Tag Manager tag inject popups?

Yes. A Custom HTML tag can load any script, and anyone with Publish access can add one. Review your Custom HTML tags and version history, remove tags you cannot explain, and turn on 2-step verification for everyone with access.

Can FunnelGuard detect injected popups?

Only partly. It runs your real journeys and alerts you when a step fails, for example because a popup covers a button or redirects the robot. It does not scan for malware or detect popups that appear only to certain visitors, so you should also check by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.