On this page
What this issue is
Most sites load code from other companies: chat widgets, analytics, review badges, fonts, A/B testing tools, tag managers. This code runs with the same power as your own code. If the company is hacked, or an account or domain used to serve the file is taken over, the file can be changed. The change then reaches every site that loads it.
Why it costs you leads or sales
Search engines read your outbound links as a sign of who you endorse. Links to spam sites can hurt trust in your pages, trigger manual actions or security warnings, and push your rankings down. AI search tools that cite sources also tend to favour sites that look clean and reliable.
The same script can do more than add links. It can redirect visitors, swap your buttons, capture form data or load ads. Visitors who see a warning or get sent away do not become leads. Fixing the cause late also means weeks of cleanup and re-review.
- Vendor hackedScript file or its host is altered
- Your page loads itScript tag still points to the vendor
- Links injectedHidden spam links added in the browser
- Search trust dropsRankings and warnings suffer
The break happens outside your own server, which is why your files look fine.
Day 0
A vendor script is altered. Your site loads it without any change on your side.
Days 1-14
Hidden links appear on every page that loads the script. Nobody notices.
Weeks 2-4
Search engines crawl the links. Rankings slip or a warning shows in Search Console.
After cleanup
Script removed, site re-reviewed, visibility slowly recovers.
How to check if your site has it
Compare source with the rendered page
Open a page, press Ctrl+U (Cmd+Option+U on Mac) for the source, then open DevTools > Elements and search for
<a href=. Links that exist in Elements but not in the source were added by JavaScript.Search for hidden links
In DevTools > Elements, search for
display:none,left:-9999px,font-size:0andvisibility:hiddennear anchor tags. Spam links are often hidden this way.List every script your page loads
In DevTools > Network, filter by JS and reload. Note each domain. Remove anything you do not recognise or no longer use.
Check what a script itself changed
In Network, click each third-party file and look for obfuscated code,
eval(,atob(or calls that createaelements.Look as a search crawler would
In Google Search Console, use URL Inspection > View crawled page > HTML to see the rendered HTML Google saw. Also check the Security issues and Manual actions reports.
Crawl the site
Use a crawler that renders JavaScript and export all external links. Sort by domain and look for unfamiliar ones.
[...document.querySelectorAll('a[href^="http"]')]
.filter(a => a.hostname !== location.hostname)
.map(a => ({
href: a.href,
text: a.textContent.trim().slice(0, 40),
visible: !!(a.offsetWidth || a.offsetHeight)
}));Any link with visible: false that you did not add is a strong warning sign. Check legitimate ones too, such as a vendor's "powered by" link.
How to fix it
Identify the offending script
In DevTools, right-click an injected link > Break on > Subtree modifications, then reload. The debugger stops on the code that inserts it and shows the source file.
Remove it right away
Delete the script tag, disable the plugin or pause the tag. Do this first, ask questions later.
Tell the vendor
Report what you found with the file URL and a screenshot. Only add the script back once they confirm it is clean.
Rule out your own site being hacked
Check that your own files, admin users and tag manager accounts are not changed. Rotate passwords and turn on two-factor sign-in.
Ask search engines to re-check
Once clean, request a review in Search Console if a security issue or manual action was reported, and re-inspect key URLs.
Find the source
Go to Plugins > Installed Plugins and deactivate one at a time, reloading the page, until the links disappear. Also check Appearance > Theme File Editor and any header/footer script plugin.
Replace the code
Delete the plugin or reinstall it fresh from the official directory. Do not keep a copy from an unknown source.
Check apps and theme
Go to Settings > Apps and uninstall suspect apps. Then open Online Store > Themes > Edit code and search theme.liquid for unknown script tags.
Check customer events
In Settings > Customer events, remove any custom pixel you do not recognise.
Review tags
Open Tags and look for Custom HTML tags you did not create. Use Versions to see who published changes and when.
Roll back and lock down
Publish a clean earlier version, then check Admin > User Management and remove users you do not know.
Check custom code
Open Site settings > Custom code (head and footer) and each page's settings. Remove unknown script tags, then publish.
Check integrations
Review Site settings > Integrations and remove unused ones.
Check tracking code
Open the funnel or website Settings and check Header and Footer tracking code, plus any custom code elements on pages. Remove unknown scripts and publish.
Check custom code
Go to Settings > Custom code and remove unknown snippets. Then review installed apps in the App Market and remove any you do not use.
Check code injection
Go to Settings > Advanced > Code Injection and clear unknown scripts from the header and footer. Check page-level injection in each page's Advanced settings.
Host critical files yourself
Download the vendor library, review it, and serve it from your own domain. Update it on a schedule.
Pin with Subresource Integrity
If you must load from a CDN, add an integrity hash so the browser blocks a changed file (see the snippet below).
<script
src="https://cdn.example.com/lib/1.2.3/lib.min.js"
integrity="sha384-REPLACE_WITH_REAL_HASH"
crossorigin="anonymous"></script>Content-Security-Policy-Report-Only: script-src 'self' https://www.googletagmanager.com https://cdn.example.com; object-src 'none'; base-uri 'self'; report-to csp-endpointBefore
- Dozens of unreviewed third-party scripts
- Anyone with tag manager access can publish
- No alert when a script changes
After
- Only scripts you need, each with a named owner
- Allowed script sources set in a CSP
- Fixed files pinned with SRI, weekly link check
How to confirm it's fixed
- The console snippet shows no unknown external links on your key pages
- Network tab shows no scripts from domains you do not recognise
- Search Console URL Inspection shows clean rendered HTML
- Security issues and Manual actions reports are empty, or a review is requested
- Tag manager version history shows only changes you made
- Passwords rotated and two-factor sign-in on for CMS, tag manager and hosting
How to prevent it happening again
- Keep a list of every third-party script, who owns it and why it is there
- Remove tags and plugins you no longer use
- Limit who can publish in your tag manager and review its change log
- Roll out a Content Security Policy, starting in report-only mode
- Use SRI for versioned files from CDNs
- Run a rendered-link check monthly on key templates
- Watch vendor security notices and update plugins promptly
How FunnelGuard handles this
FunnelGuard covers this issue partly. It checks for third-party script failures only: when a script on your journey fails to load or breaks a step, the robot visitor sees it, re-checks from a second region and sends one alert with a screenshot and a likely cause.
What it does not do: it does not scan your pages for injected or hidden links, does not compare script contents over time, and does not judge whether a script is malicious. A hacked script that loads fine and quietly adds links will not trigger an alert.
To cover the rest by hand, run the console snippet above on your key pages each month, review Search Console's Security issues report, audit your tag manager change log, and use a rendered-HTML crawler for a site-wide link export. If a script starts breaking forms or buttons, FunnelGuard's alert can be the first hint that something changed. FunnelGuard has a Free plan with 1 site and 2 journeys, and a free read-only website audit.
Questions people ask
How can a third-party script inject links into my website?
The script runs with the same permissions as your own code, so it can add elements to the page. If the vendor or its hosting is hacked, the changed file can insert hidden anchor tags for every site that loads it. The links appear in the browser, not in your own files.
How do I find hidden spam links on my website?
Compare the page source (Ctrl+U) with the rendered DOM in DevTools > Elements, and run a console snippet that lists external links and whether they are visible. In Search Console, URL Inspection > View crawled page shows the HTML Google saw. Links you did not add, especially hidden ones, are the red flag.
Why do I see links in DevTools but not in View Source?
View Source shows the HTML sent by your server. DevTools shows the page after JavaScript has run. Links that appear only in DevTools were added by a script, which is exactly how injected spam links work.
Can Google Tag Manager be used to inject spam links?
Yes. A Custom HTML tag can add links to any page, so an attacker with tag manager access can do it without touching your site files. Review your tags and Versions history, remove unknown users and turn on two-factor sign-in.
Does Subresource Integrity stop a hacked script?
It does for fixed, versioned files. The browser refuses to run the file if its hash no longer matches. It does not suit scripts the vendor changes in place, such as most tag managers and chat widgets, so pair it with a Content Security Policy.
Will hidden spam links hurt my Google rankings?
They can. Search engines may treat them as link spam or a sign of a compromised site, which can lead to lower visibility, warnings or a manual action. Remove the cause quickly and request a review if Search Console reports a problem.
Does FunnelGuard detect injected links from a compromised script?
Only partly. It detects third-party script failures on your journeys and alerts you, but it does not scan for injected or hidden links. Check those by hand with a rendered-page link check and Search Console.
Related issues
- SEO-312Site hacked with spam pages or cloaked redirectsFix guide
- SEO-313Malware flagged by Google Safe BrowsingFix guide
- SEO-316Cloaking: different content to bots and usersFix guide
- SEO-315Sneaky mobile redirects to ad networksFix guide
- SEO-319Spam outbound links from comments or widgetsFix guide
- SEO-314Deceptive site warning (phishing)Fix guide