On this page
What this issue is
A Content Security Policy is a security rule your server sends in an HTTP header called Content-Security-Policy (or in a <meta http-equiv> tag). It lists the places the browser is allowed to load scripts, styles, frames, images and network calls from. Anything not on the list is blocked.
Refused to load the script 'https://www.googletagmanager.com/gtm.js?id=GTM-XXXX' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.Why it costs you leads or sales
A blocked script is a silent failure. Depending on what is blocked, you can lose different things:
| Blocked item | CSP directive usually involved | What you lose |
|---|---|---|
| Google Tag Manager or a pixel script | script-src | Conversions and audiences stop reaching GA4, Google Ads, Meta and others |
| Tracking hit (the request a tag sends) | connect-src or img-src | The tag loads but its data never arrives |
| Form, booking or chat embed | frame-src | Visitors see an empty box instead of the form |
| Inline script or inline event handler | script-src without nonce or hash | Buttons or form logic stop working |
| Payment or captcha widget | script-src and frame-src | Checkout cannot be completed |
If tracking is blocked, your ad platforms get no conversion data and bidding gets worse. If a form or checkout is blocked, you lose the lead or sale directly.
- Ad clickVisitor lands on the page
- Page loadsHTML and CSP header arrive
- Script blocked by CSPTag, form or widget refused
- Conversion trackedNo hit sent
- Lead or saleMay fail if the form is blocked
The page loads, but the blocked tag or form never runs, so everything after it is lost.
The browser reads the policy, refuses the script and the tag never sends its hit.
How to check if your site has it
Open the page in Chrome
Use a private window so extensions do not interfere. Open the page where the form, tag or widget should work.
Open DevTools and the Console
Press F12 (or Cmd+Option+I on Mac) and select Console. Reload the page. Look for red messages that start with 'Refused to load', 'Refused to connect', 'Refused to frame' or 'Refused to execute inline script'.
Read the blocked source and directive
The message names the blocked URL and the directive that blocked it, for example script-src or frame-src. Note both.
Read your current policy
In DevTools open Network, click the page request (the first one), and look under Response Headers for Content-Security-Policy. Also search the HTML for a meta tag with http-equiv='Content-Security-Policy'.
Walk the whole funnel
Repeat on every step: landing page, form, thank-you page, checkout. Policies can differ by page or path.
How to fix it
The fix is to add only the exact source you need to the correct directive. Do not remove the policy or add * or 'unsafe-inline' as a shortcut. That weakens the protection the policy exists to give you.
| Console message says | Add the source to |
|---|---|
| Refused to load the script | script-src (or script-src-elem) |
| Refused to connect | connect-src |
| Refused to frame | frame-src |
| Refused to load the image | img-src |
| Refused to execute inline script | Use a nonce or hash in script-src, or move the code to a file |
Content-Security-Policy: default-src 'self'; script-src 'self' https://www.googletagmanager.com; connect-src 'self' https://www.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com; img-src 'self' data: https://www.google-analytics.com https://www.googletagmanager.com; frame-src 'self' https://www.googletagmanager.comEach tool needs its own domains. Take them from the console errors and from the vendor's own CSP documentation, not from a guess. Where you must run inline code, use a nonce: a random value your server generates per page load and puts in both the header and the script tag.
<!-- Header: Content-Security-Policy: script-src 'self' 'nonce-r4nd0mValue' -->
<script nonce="r4nd0mValue">
window.dataLayer = window.dataLayer || [];
</script>Find the source of the header
Check security or headers plugins (for example a plugin with an HTTP headers or CSP setting), your host's dashboard and the .htaccess file. The setting depends on which one you use.
Add the blocked source
Add the domain to the matching directive and save. Clear any page or CDN cache afterwards.
Know the limits
Shopify controls the main storefront headers. If a block comes from an app, theme code or a custom meta tag, remove or edit that. Checkout pages are controlled by Shopify.
Check theme.liquid
Search the theme for a Content-Security-Policy meta tag and update it, or contact the app developer if an app is injecting the policy.
Allow GTM itself
Add https://www.googletagmanager.com to script-src. For Custom HTML tags that use inline code, you need a nonce or must move the code to a hosted file.
Allow each tag's domains
In Preview mode, note which tags are blocked, then add each vendor's script, connect and image sources.
Check for a meta tag
Look in Project settings, Custom code (head) for a CSP meta tag. Edit it there and publish.
Check any proxy in front
If you use a CDN or firewall in front of Webflow, the header may be set there instead.
Check custom code and domain setup
Look in the funnel or site settings for custom head code containing a CSP meta tag. If you proxy the domain, check that layer too.
Check custom code
Wix manages most headers itself. Look in Settings, Custom code for any meta tag you added, and remove or fix it.
Check code injection
Open Settings, Developer Tools, Code Injection and look for a CSP meta tag. Squarespace controls the server headers, so you can only change what you injected.
Edit the header in your server or app
Change the Content-Security-Policy value in nginx (add_header), Apache (Header set), your framework middleware or your CDN rules. Reload the service.
Test in report-only first
Use the Content-Security-Policy-Report-Only header to see what would be blocked without enforcing it.
add_header Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self' https://www.googletagmanager.com" always;Before
- script-src allows only 'self'
- GTM and pixel scripts refused
- Console shows 'Refused to load the script'
- Conversions missing in ad platforms
After
- script-src, connect-src and frame-src list the exact vendor domains
- Tags load and send their hits
- Console is free of CSP errors
- Conversions appear in reports
How to confirm it's fixed
- Reload each funnel page with the Console open and see no 'Refused to...' messages
- In the Network tab, the blocked scripts now return a normal status
- GTM Preview or the platform's debug tool shows the tag firing
- The form, chat or booking widget appears and works
- A test conversion shows up in GA4 DebugView or the ad platform's test events
- Retest in a private window and on mobile
How to prevent it happening again
- Before adding any new tag, widget or embed, list its domains and update the policy first
- Roll out policy changes in report-only mode, then enforce
- Keep the policy in version control so changes are reviewed
- Re-check the console on every funnel step after a policy or theme change
- Remove domains of tools you no longer use
- Run scheduled checks of the live funnel so a new block is found quickly
Day 1
A developer tightens the CSP to improve security.
Day 1
The Meta Pixel domain is missing from the policy and is blocked.
Day 5
Reported conversions in the ad platform drop; nobody sees a visible error.
Day 9
Someone opens the console, finds the error and adds the domain.
How FunnelGuard handles this
FunnelGuard detects this issue only partly. It runs your real customer journeys with a robot visitor on a schedule and picks up console errors on the steps it visits. A CSP block writes a console error, so it can show up that way.
What FunnelGuard does not do is explain the policy. It does not tell you which CSP directive blocked the script, read your header or tell you which domain to add. A console error alone does not name the cause.
To cover the rest by hand: when an alert or a failed step points to a console error, open the page yourself, read the 'Refused to...' message and note the blocked URL and directive. Then compare it with the Content-Security-Policy header in DevTools, Network, Response Headers, and follow the fix steps above. FunnelGuard also checks the tracking hits sent to ad and analytics platforms, so a missing hit can confirm that a tag is not working, but you still need the console to find out why.
There is a Free plan (1 site, 2 journeys, daily checks, no card). Paid plans start at $39/month with a 3-day free trial.
Questions people ask
Why is my script blocked by Content Security Policy?
The browser blocks a script when its source is not on the allow list in your Content-Security-Policy, usually under script-src. The console message names the blocked URL and the directive. Add that exact source to the right directive and reload.
How do I fix 'Refused to load the script because it violates the following Content Security Policy directive'?
Open the console, copy the blocked URL and note the directive in the message. Add that domain to the same directive in your CSP header, for example script-src, then clear caches and reload. Test every funnel step afterwards.
Why is Google Tag Manager not loading on my site?
One common cause is a CSP that does not allow https://www.googletagmanager.com in script-src. Check the console for a 'Refused to load' message. Tags inside GTM may need their own domains in script-src, connect-src and img-src.
How do I find out which CSP directive is blocking my tag?
The console error names it, for example script-src, connect-src or frame-src. You can also view the full policy in DevTools under Network, the page request, Response Headers. Match the blocked source type to the directive.
Is it safe to add unsafe-inline to my CSP?
It is not recommended. 'unsafe-inline' allows any inline script, which removes much of the protection a CSP gives. Use a nonce or hash for the specific inline scripts you need, or move the code into a hosted file.
How can I test a CSP change without breaking my site?
Use the Content-Security-Policy-Report-Only header. The browser logs what it would block but does not enforce it. When the console is clean on every funnel step, switch to the enforcing header.
Can a CSP block a form or checkout?
Yes. If the form is an embed, frame-src must allow its domain. If the form relies on a script or a network call, script-src and connect-src must allow them. A blocked form can show as an empty box or a button that does nothing.
Does FunnelGuard tell me which CSP rule is blocking my script?
No. FunnelGuard detects the console error on a funnel step, but it does not explain the CSP cause or name the directive. You read the 'Refused to...' message in the console and compare it with your policy header.
Related issues
- PRF-117Console error on a funnel stepFix guide
- PRF-116Uncaught JavaScript exception on page loadFix guide
- PRF-124CORS error blocking API call from the pageFix guide
- PRF-126Mixed content blocked (http script on https page)Fix guide
- PRF-120JS error only after clicking submit breaks the formFix guide
- PRF-134Button does nothing on click (dead click)Fix guide