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.
- Ad clickVisitor lands on your page
- Injected popupRogue script opens an overlay or redirect
- Form or checkoutCovered or never reached
- Lead or saleNot recorded
The rogue script runs on the landing page and the visitor never reaches the form.
An overlay you did not add sits on top of your call to action.
How to check if your site has it
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.
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.
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.
Check the page source
View source and search for
<script src=,eval(,atob(,document.write,window.openand long encoded strings.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.
cd /path/to/wordpress
grep -rIl --include=*.php --include=*.js -E "eval\(base64_decode|atob\(|document\.write\(unescape" wp-content | head -50How 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.
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.
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.
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.
Rotate credentials
Change all admin, hosting, FTP/SFTP and database passwords, and regenerate the salts in wp-config.php.
Audit Custom HTML tags
In Tags, filter by type Custom HTML and read every one. Pause any you cannot explain.
Check version history
Open Versions and review recent changes and who published them.
Review users
In Admin > User Management, remove people who should not have Publish access and turn on 2-step verification.
Check theme code
In Online Store > Themes > Edit code, search theme.liquid for unknown script tags. Compare with a fresh copy of the theme.
Review apps and staff
Remove apps you do not use, since app scripts load on every page. Check Settings > Users and permissions for unknown staff.
Check Custom pixels
In Settings > Customer events, review custom pixels for code you did not add.
Check custom code
Review Site settings > Custom code (head and footer) and each page's custom code for unknown scripts.
Review embeds and integrations
Look at Embed elements and connected apps, and remove anything unfamiliar.
Check Custom Code
In Settings > Custom code, review every snippet and remove any you did not add.
Review apps and collaborators
Remove unused apps and unknown contributors.
Check Code Injection
In Settings > Developer Tools > Code Injection, review the Header, Footer and Lock Page fields, plus per-page code injection.
Review contributors
Remove unknown contributors and change your password.
Check tracking code fields
In each funnel's Settings, review the Head and Footer tracking code, and per-page custom code, for unknown scripts.
Check custom code elements
Search funnel pages for Custom JS/HTML elements you did not add, and review team members.
Compare with version control
Diff the live files against your repository or last clean deploy. Redeploy from clean source.
Check server and templates
Inspect templates, includes, .htaccess or server config and any CMS database fields that output HTML.
Rotate secrets
Change server, deploy, database and API credentials.
Update everything
Update the CMS, plugins, themes and apps. Remove abandoned ones.
Change passwords and turn on two-step login
Do this for every admin, the host, the tag manager and the domain registrar.
Remove unknown users and API keys
A hidden admin lets the attacker come back.
Replace untrusted third-party scripts
If the script came from a vendor, contact them and remove or replace the widget.
Ask for a review if flagged
If a browser or Google warning appeared, request a review once the site is clean.
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
- 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
- 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
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' https://www.googletagmanager.com https://www.google-analytics.com; report-to csp-endpointHow 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.
Related issues
- OPS-146Fake CAPTCHA / ClickFix malware overlayFix guide
- OPS-151Browser extension-like injected ads on siteFix guide
- OPS-140Malware/redirect hack sending mobile/ad visitors elsewhereFix guide
- OPS-141Conditional redirect hack only for search/ad referrersFix guide
- OPS-145Crypto-miner script injectedFix guide
- OPS-148Rogue admin user createdFix guide