Security & Governance
Every time someone publishes a GTM container, they are deploying code to production. Not configuration. Not settings. Code — arbitrary JavaScript that executes in every visitor’s browser, with full access to the DOM, cookies, form inputs, and network requests.
Most organizations deploy GTM with far less oversight than they would apply to a code change in their main repository. There is no code review. There is no automated testing pipeline. In many cases, anyone with Editor access can add a Custom HTML tag and push directly to production without another human reviewing it.
This section covers how to change that.
Why GTM security is underestimated
Section titled “Why GTM security is underestimated”GTM’s interface is designed to look like a configuration tool. You fill out forms, pick from dropdowns, set conditions. It feels more like a CMS than a code deployment system. This design choice — which makes GTM accessible to non-engineers — also creates a dangerous illusion: that GTM changes are somehow lower-risk than code changes.
They are not. A Custom HTML tag accepts raw JavaScript and executes it with no restrictions. A variable can call any function on the page. A trigger can fire on any user interaction. The GTM container loading on your site has the same capabilities as an inline <script> tag placed directly in your HTML.
The difference is that your <script> tags go through a code review process. Your GTM tags probably do not.
What this section covers
Section titled “What this section covers”The security baseline
Section titled “The security baseline”Before going deeper into any of these topics, here is the minimum security posture every GTM implementation should have:
Access control. Nobody has more access than they need. Analysts get read-only. Implementers get edit. Only leads get publish. Admins are limited to one or two named individuals who understand the security implications.
Change documentation. Every version has a description. Every tag has a name and a documented purpose. Nobody publishes a “test” version on Friday afternoon with no notes.
Regular audits. At minimum once per month, someone reviews new Custom HTML tags and checks outbound network requests. Monthly is the minimum — weekly is better for high-traffic containers.
Version control. Container exports are committed to Git. Diffs are reviewable. Rollback is practiced, not theoretical.
CSP header. A Content Security Policy that restricts what scripts can load and where data can be sent. Not perfect, but it limits the blast radius of a successful injection.
None of this is complicated. All of it requires organizational commitment. The technical implementation is the easy part.