Your Security Team Wants to Remove ‘unsafe-inline’. What Does That Mean for Your Analytics Tags?

If you work with Google Tag Manager, Adobe Launch, analytics, experimentation, consent management, or other marketing technology, you may eventually hear something like this from your security team:

“We want to remove 'unsafe-inline' from our Content Security Policy and move to a nonce-based CSP.”

For a security engineer, that request may be perfectly clear.

For an analytics or marketing technology practitioner, it can raise a much more practical question:

What is going to break?

Content Security Policy (CSP) is an important security mechanism, but changes to CSP can have significant implications for Google Tag Manager, experimentation platforms, consent management tools, advertising pixels, and other third-party technologies running on your website.

Let’s look at what 'unsafe-inline' means, why security teams want to remove it, and what analytics teams need to consider when that happens.

What Is Content Security Policy?

Content Security Policy is a browser security mechanism that allows a website to specify which resources the browser should be allowed to load or execute.

A site can use CSP to control things such as:

  • JavaScript
  • CSS
  • Images
  • Fonts
  • Frames
  • Network connections
  • Other external resources

For example, a CSP might contain a script-src directive that determines where JavaScript is allowed to come from.

A simplified policy could look like this:

script-src 'self' https://www.googletagmanager.com

This essentially tells the browser:

Allow scripts from this website itself and from googletagmanager.com.

Scripts from sources that aren’t permitted by the policy can be blocked by the browser.

That makes CSP an important layer of protection against attacks such as Cross-Site Scripting (XSS).

So What Is 'unsafe-inline'?

JavaScript doesn’t always come from an external .js file.

It can also be written directly into a page:

<script>
  doSomething();
</script>

That’s an inline script.

A CSP can allow inline JavaScript by including:

'unsafe-inline'

For example:

script-src 'self' 'unsafe-inline' https://www.googletagmanager.com

The problem is right there in the name.

Unsafe inline.

Allowing inline JavaScript broadly weakens one of the protections CSP is designed to provide.

If malicious JavaScript somehow gets injected into a page, a strict CSP can potentially prevent that JavaScript from executing. But allowing 'unsafe-inline' can make that protection significantly weaker.

That’s why security teams often want to remove it.

The Alternative: Nonce-Based CSP

One alternative is to use a nonce.

A nonce is a unique, unpredictable value generated by the server for a particular page response.

For example, the CSP might say:

script-src 'self' 'nonce-X7a92kLm'

An approved inline script would then include that same nonce:

<script nonce="X7a92kLm">
  doSomething();
</script>

The browser sees that the nonce on the script matches the nonce permitted by the CSP and allows the script to execute.

An inline script without the correct nonce is blocked.

And the next page response should use a new nonce.

Instead of saying:

“Allow inline JavaScript.”

you’re effectively saying:

“Allow only the inline JavaScript explicitly authorized for this page.”

That’s a significant security improvement.

Where Analytics and MarTech Get Complicated

This is where analytics practitioners need to pay attention.

Modern websites often run far more JavaScript than the application developers wrote themselves.

Consider everything that might be running on a typical site:

Google Tag Manager, GA4, advertising pixels, consent management platforms, A/B testing tools, personalization platforms, chat tools, heatmaps, session recording tools, surveys, affiliate tracking, and numerous other third-party technologies.

Some of these technologies don’t simply load one JavaScript file.

They may dynamically create scripts, inject elements into the page, make requests to additional domains, load resources from other locations, or execute code created through a tag management or experimentation interface.

That’s why this can become a problem:

A security team removes 'unsafe-inline', the website still loads normally, and everyone assumes everything is fine.

But behind the scenes, something may have stopped working.

An experiment may no longer execute, a marketing tag may fail, a consent-dependent tag may behave differently, a conversion event may disappear or a particular GTM Custom HTML tag may be blocked.

The website can look completely normal while measurement is broken.

Google Tag Manager Deserves Special Attention

GTM makes CSP particularly interesting because the container is specifically designed to execute and manage other tags.

Allowing googletagmanager.com in script-src doesn’t automatically mean that everything deployed through your GTM container will work.

Your container might include tags from multiple vendors.

It might contain Custom HTML.

Those tags may load additional JavaScript or communicate with other domains.

Different CSP directives may therefore come into play.

This is an important distinction:

Making GTM itself CSP-compatible does not necessarily make every tag inside GTM CSP-compatible.

Your actual implementation needs to be tested.

Experimentation and Personalization Tools Can Be Even More Complex

A/B testing and personalization platforms deserve similar scrutiny.

Their purpose is often to modify what the user sees or how the page behaves.

An experimentation platform may load its primary library and then dynamically execute experiment code, modify page elements, inject styles, or load additional resources.

A stricter CSP can potentially affect those behaviors.

So the question shouldn’t simply be:

“Is Vendor X allowed in our CSP?”

A better question is:

“Does our actual implementation of Vendor X work correctly under this CSP?”

Those are very different questions.

CSP Isn’t Just About script-src

Another common mistake is focusing exclusively on JavaScript.

A MarTech platform may need permission under several CSP directives depending on what it does.

For example, you may need to consider:

script-src
connect-src
img-src
style-src
frame-src
font-src

An analytics library might successfully load under script-src, for example, but its measurement request could still be blocked by connect-src.

A personalization tool might execute correctly but have a required style blocked by style-src.

Again, the page itself may still look mostly normal.

Don’t Solve the Problem by Blindly Allowlisting Everything

When something stops working after a CSP change, the temptation is to keep adding domains or relaxing directives until the browser stops reporting errors.

That’s not a great CSP strategy.

You can end up with a policy that technically exists but provides much less protection than intended.

Security, development, and analytics teams should instead understand:

What is this resource? Why is it required? Which technology requires it? What CSP directive governs it? Does it actually need to be allowed?

This is also a good opportunity to discover old marketing and analytics technology that shouldn’t be running anymore.

You may find tags for campaigns that ended years ago, vendors nobody remembers using, abandoned pixels, old Custom HTML tags, and other technical debt.

A CSP review can therefore become an unexpected MarTech governance exercise.

What Analytics Teams Should Test After a CSP Change

If your organization is moving toward a stricter CSP, don’t limit testing to whether the website loads.

Analytics and MarTech functionality should be explicitly validated.

At minimum, review:

  • Browser console CSP violations
  • Google Tag Manager loading and execution
  • GA4 page and event collection
  • Key conversion events
  • Consent behavior
  • Advertising and remarketing tags
  • Experimentation and personalization
  • Custom HTML tags
  • Third-party network requests
  • Forms and lead tracking
  • Cross-domain measurement, where applicable

And don’t just test the homepage.

Different sections of the website may trigger completely different tags and technologies.

Security and Analytics Shouldn’t Be Opposing Teams

Sometimes these conversations turn into:

Security: “We need to block this.”

versus:

Marketing: “But we need our tracking.”

That’s the wrong way to approach CSP.

The security team’s concern is legitimate. Broadly allowing inline JavaScript can weaken CSP protections.

The analytics team’s concern is also legitimate. Measurement, experimentation, consent, and other business-critical functionality still need to operate correctly.

The goal should be:

Implement the strongest practical security policy while explicitly supporting the legitimate technologies the business needs.

That requires collaboration between security, development, analytics, and marketing technology teams.

One Final Warning: Don’t Assume No Errors Means Good Data

This is perhaps the most important point for analytics practitioners.

When a CSP change breaks an obvious application feature, someone usually notices quickly.

When it breaks analytics, you may not know for days or weeks.

The page loads.

The customer completes the purchase.

The confirmation page appears.

But the conversion event never reaches your analytics platform.

Everything looks fine.

Your data isn’t.

So whenever CSP policies change, treat analytics validation as part of the deployment—not something you investigate after someone notices the numbers suddenly dropped.

Need Help With CSP and Your Analytics Implementation?

Modern analytics implementations sit at the intersection of marketing, data, development, privacy, and security.

At Optizent, we help organizations implement and troubleshoot GA4, Google Tag Manager, experimentation and other analytics technologies—including situations where security requirements such as Content Security Policy affect how those technologies operate.

If your security team is tightening CSP and you’re concerned about what it could mean for your analytics and marketing tags, we can help you evaluate the implementation, identify potential issues, and validate that your measurement continues to work correctly.

Contact Optizent to discuss your analytics and MarTech implementation.