Skip to content

Google Tag Manager at Checkout: Risks and How to Stay Safe

Laís Peixoto

By Laís Peixoto

Growth Marketer, Proteside

Published · 5 min read

Payment QR code with a fake layer peeling off on top, next to the Proteside shield. Payment methods: Credit card, Debit card, and Pix.

Google Tag Manager (GTM) can become a gateway for data theft at checkout when an attacker adds malicious code to a container the page loads. The defense combines fewer tags, control over who publishes and checking what actually reaches the browser.

Google Tag Manager (GTM) can become a gateway for data theft at checkout when an attacker adds malicious code to a container the page loads. That code can read fields the page controls or overlay fake forms; fields inside the payment provider's frame (an iframe served from another address), however, are not directly readable by the page's scripts. The defense combines fewer tags, control over publishing and checking what actually reaches the browser.

Why the tag manager has so much power

Google Tag Manager lets marketing teams install pixels and measurement tools without depending on a developer. Once the code snippet is on the site, on every visit the customer's browser fetches the container (the published package of tags) from Google and runs whatever is in it, including custom HTML tags, which accept any code. Even so, that code cannot directly read what is inside the payment frame served by the provider.

In practice, changing what runs on the checkout does not require touching the store's server: publishing a new version of the container is enough. The official help documentation provides four access levels per container (read, edit, approve and publish), and only the last one puts changes live. The PCI SSC guidance on payment page security, from March 2025, lists tag management among the scripts criminals can manipulate to capture payment data.

How Tag Manager shows up in attacks

The pattern appears in reports on Magecart, the name given to those who steal card data by inserting code into the payment page.

  • The criminal's own container. In 2022, Recorded Future counted 569 infected online stores, 314 of them through Tag Manager containers. In general, the attackers created their own container and inserted it into the hacked site, which let them change the code without going back to the victim's server. The infection lasted 3.5 months on average.
  • A flaw in a checkout plugin. In May 2026, Sansec reported that attackers, without logging in, were exploiting a flaw in Funnel Builder, a checkout plugin for WooCommerce, to write fake Tag Manager scripts into the external scripts field. The fix came in version 3.15.0.3.
  • A custom tag as a loader. In June 2026, Sansec described an attack whose loader was a real Tag Manager container, served from Google's domain.
  • Magento stores. In CosmicSting, a Magento flaw exploited in 2024, Sansec recorded a group that loaded malicious code even through Tag Manager.

Why it goes unnoticed

The address is Google's, which nobody finds odd. Sansec maintains a public list of malicious containers, whose total changes over time. The company documents chained containers and calls attention to excessive trust in Google domains in the page's content security policy (CSP). Allowing a trusted domain does not, by itself, make the code that comes from it safe. The code is also not in the store's files, and the criminal's container does not appear in the merchant's dashboard.

What to do

  1. Remove Tag Manager from the payment page or keep only the essentials. When PCI DSS requirement 6.4.3 applies to the organization's environment and validation method, payment page scripts need justification and control; even outside that specific obligation, fewer tags means a smaller attack surface.
  2. Block custom code tags at checkout. Google documents a blocklist, applied by the page's own code, that prevents custom HTML tags from running even if someone publishes them.
  3. Limit who can publish. Remove that access level from anyone who does not need it, including agencies and former employees.
  4. Require 2-step verification. An account setting makes Tag Manager require it before changes to custom HTML tags, custom JavaScript variables and permissions.
  5. Use versions. Each publication creates a version, and you can republish an earlier one. Formal approval exists only in Tag Manager 360; in the free version, agree on who reviews before publishing.
  6. Check the containers the page loads. Their IDs start with GTM-. If an unknown one appears, Sansec advises treating the site or the administrator account as possibly compromised.
  7. Monitor what runs in the customer's browser. Requirement 11.6.1, when applicable, covers detecting unauthorized changes to payment pages and relevant HTTP headers as received by the browser. See what PCI DSS requires for third-party scripts and the PCI DSS compliance solution.

Hands-on test to find unexpected containers

  1. Open the checkout in a private window, without an administrator login, and repeat on a phone.
  2. In the developer tools, list the requests to googletagmanager.com and the GTM- IDs loaded directly or by other scripts.
  3. Compare them with the approved inventory. Also check for tags from the agency's container, from plugins or from old integrations.
  4. Review publishing permissions and version history; investigate each unknown ID before removing it.
  5. Repeat the test after changes and with automated monitoring: some attacks activate only under specific conditions.

The result of a single manual inspection is not proof that there is no malicious code.

Frequently asked questions

Is Google Tag Manager insecure?

Not in itself. The risk lies in who publishes, in what the container can run at checkout and in containers inserted without the store's knowledge.

If the card form belongs to the payment gateway, is Tag Manager still a risk?

Yes: the page that contains the provider's iframe can be compromised to display a fake form or to swap a Pix QR code (Pix is Brazil's instant payment system) outside the iframe, even though it has no direct access to fields isolated on another origin. Whether you must validate requirements 6.4.3 and 11.6.1 depends on your PCI classification: in the 2025 revision of SAQ A, those requirements were removed from the questionnaire and replaced by an eligibility criterion on script attacks for certain embedded checkouts. Confirm with your acquirer or assessor. See card fields hosted by the gateway and what Magecart is.

How can you tell if there is an unfamiliar container on the store?

Open the checkout as a customer, see which GTM- IDs it loads and compare them with those in your account. The full walkthrough is in how to detect malicious code at checkout.

Wrapping up

GTM speeds up publishing and, without clear rules on who publishes, widens the attack surface. That is why payment page integrity needs to be checked on the buyer's side, which is what Proteside does: it compares the credit card form, the debit card form and the Pix QR code displayed with what the store issued, blocks the swap before confirmation and records the evidence.

How we create our content

Back to blog