Back to the help center

Integrations

Block hard-coded scripts with data attributes

Let GetCookies control hard-coded scripts with data attributes

If some scripts aren’t in GTM, you can let GetCookies control them via attributes.

How to wrap scripts

Add type="text/plain" and a data-cookieconsent category:

<!-- Analytics -->
<script
  data-cookieconsent="analytics"
  src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"
  type="text/plain"></script>

<!-- Marketing -->
<script data-cookieconsent="marketing" type="text/plain">
  /* Meta Pixel code */
</script>

Categories to use

  • necessary (always allowed)
  • analytics
  • marketing
  • preferences

How it works

  • The browser won’t execute scripts marked text/plain until GetCookies rewrites them after consent.
  • When a user denies a category, those scripts remain inert.

Troubleshooting

  • If a script still fires early, confirm it’s wrapped and not duplicated elsewhere.
  • Clear caches/CDN so the updated markup ships.
  • For inline ads/pixels, ensure the code is inside the text/plain tag.

Still stuck?

Email [email protected] with your domain and what you tried. Signed-in customers can also open a ticket from the dashboard.