On this page
What this issue is
Ad networks, affiliate tags, popups and widgets load JavaScript from servers you do not control. That code runs with the same power as your own. If the network is sloppy, hacked, or sells space to bad advertisers, the script can redirect the page, open a new tab, or replace your page with an ad or scam.
Why it costs you leads or sales
A visitor who is sent away never sees your form, button or checkout. You still paid for the click. Redirects also hurt trust: browsers and security tools can flag your site as unsafe, and visitors who land on a scam page may blame you.
- Ad clickVisitor arrives from your campaign
- Landing page loadsThird-party ad script also loads
- Script redirectsVisitor sent to another domain
- Form or checkoutNever reached
- ConversionNot recorded
The script fires after the landing page loads, so every later step is lost.
Example: if a script redirects a share of mobile visitors, fewer of them reach the form. Numbers are illustrative.
How to check if your site has it
Reports from customers like "your site sent me somewhere else" are the usual first sign. Another sign is a drop in conversions on one device type or country with no change on your side.
Reproduce it
Open the page in a private window, on a phone if possible, arriving from the same ad or link. Try a few times and with a VPN set to your target countries if your terms allow it.
Record the network
In Chrome open DevTools, go to Network, tick Preserve log, and reload. Look for the first request to a domain you do not recognise just before the page changes.
Check the initiator
Click that request and open the Initiator tab. It shows which script started it. That script, or the tag that loads it, is your culprit.
Compare with a clean load
Block the suspect domain in DevTools (right-click the request, Block request domain) and reload. If the redirect stops, you have found it.
List every tag source
Check your theme, plugins, Google Tag Manager container and any custom code fields for the script or its loader.
The page loads, the script runs, and the visitor ends up somewhere else.
How to fix it
Remove or disable the script first, then work out how it got there. If the redirect came from the ad network itself, contact their support and consider switching. If it came from an account or plugin you did not expect, treat it as a security incident.
Disable suspect plugins
Under Plugins, deactivate ad, popup and header/footer script plugins one at a time and retest.
Check header and footer code
Look in Appearance > Theme File Editor (header.php, footer.php) and any Insert Headers and Footers style plugin for unknown script tags.
Scan and update
Update core, themes and plugins, and run a malware scan with a security plugin you trust.
Check theme code
Go to Online Store > Themes > Edit code and search theme.liquid for unknown script tags.
Review apps
Under Settings > Apps, remove apps you do not recognise or no longer use, then check for leftover code in the theme.
Check custom pixels
Under Settings > Customer events, review custom pixels and remove unknown ones.
Review Custom HTML tags
Open Tags and look for Custom HTML tags that load external scripts or contain
location.Use Preview mode
Run Preview on the affected page to see which tag fires before the redirect, then pause or delete it.
Check the version history
Open Versions to see who published recent changes and roll back if needed.
Check custom code
Review Project settings > Custom code and each page's settings for head and footer scripts.
Check embeds
Search for Embed elements that load third-party ad code.
Republish
Publish the site after removing the script.
Review custom code
Open Settings > Custom code and remove unknown snippets.
Check connected apps
Remove marketing apps you do not use.
Check code injection
Open Settings > Advanced > Code Injection and check the Header, Footer and page-level fields.
Check code blocks
Search pages for Code blocks that load third-party scripts.
Search the codebase
Search templates for
<script src=pointing to domains you do not recognise and forwindow.locationorlocation.hrefassignments.Check the server
Compare files with your repository and look for recently changed files.
Contact or replace the network
Report the redirect to the ad network with the request details from DevTools. If they cannot stop it, remove them.
Rotate access
If the script was added without your knowledge, change passwords for your CMS, tag manager and hosting, and remove unused users.
Keep ad scripts off key pages
Do not load ad network code on landing pages, forms and checkout unless you need it there.
<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://www.googletagmanager.com https://www.google-analytics.com;">A Content Security Policy (CSP) tells the browser which domains may run scripts. The snippet is a starting point only: add every domain you genuinely use, or those tools will break. Test in report-only mode first using the Content-Security-Policy-Report-Only header.
How to confirm it's fixed
- Load the page 10 times on desktop and mobile without being redirected
- Test from the same ad or link source that showed the problem
- Check the Network tab shows no requests to the suspect domain
- Confirm the form submits or checkout loads from start to finish
- Watch conversions by device and country for a week
How to prevent it happening again
- Keep a written list of approved third-party scripts and their owners
- Limit who can publish in your tag manager and CMS, and use two-step login
- Avoid ad networks on lead form and checkout pages
- Review the tag manager version history monthly
- Use a CSP in report-only mode to see unexpected domains
- Re-test key journeys on mobile after every tag or plugin change
How FunnelGuard handles this
FunnelGuard detects this issue only partly. It runs your real customer journeys on a schedule, from the EU or the US. If a script sends the robot away so a step cannot be completed, such as the form not being found or the checkout not loading, the step fails. The failure is re-checked from a second region before one alert goes out with a screenshot and a likely cause.
Questions people ask
Why is my website redirecting visitors to another site?
A common cause is a third-party script, such as an ad network tag, popup or injected malware, that changes the page address. Use browser DevTools with Preserve log on to find the first request to an unknown domain and check its Initiator to see which script started it.
How do I find which script is causing a redirect?
Open DevTools, go to Network, tick Preserve log and reload. Find the request just before the page changes, then open its Initiator tab. Blocking that domain and reloading confirms whether it is the cause.
Why does the redirect only happen on mobile or for some visitors?
Many redirect scripts target specific devices, countries, referrers or first visits to avoid being noticed by site owners. Test on a real phone, arrive from the same ad or link, and try from the affected region where your terms allow it.
Can Google Tag Manager cause redirects?
Yes. A Custom HTML tag in a container can load any script, including one that redirects. Check Preview mode, review the version history and limit who can publish changes.
Is a redirect from an ad script a sign my site was hacked?
Not always. The ad network itself may be serving bad ads. But if you cannot explain how a script got onto your site, treat it as a possible compromise: rotate passwords, remove unused users and check for other changes.
Can FunnelGuard detect redirects from ad scripts?
Partly. It catches cases where the redirect stops a monitored journey step from completing and sends an alert with a screenshot. It does not scan scripts for malicious code and may miss redirects that fire only for certain devices, regions or ad sources.
Will a Content Security Policy stop script redirects?
It can limit which domains scripts may load from, which blocks many unwanted ad scripts. It will not stop a script from a domain you have allowed, and a policy that is too strict can break your own tags, so start in report-only mode.
Related issues
- OPS-195Magecart / card skimmer script on checkoutFix guide
- OPS-196Unknown third-party domain appears on checkout pageFix guide
- OPS-197Compromised npm/CDN library serving malicious codeFix guide
- OPS-198Abandoned script domain re-registered by attackerFix guide
- OPS-199Tag manager container edited by unknown userFix guide
- OPS-205Third-party pixel collecting PII without consentFix guide