Analytics

Tag Manager: Introducing Custom Templates

Google Tag Manager and Tag Manager 360 help you more easily and safely deploy tags for all your marketing and measurement tools. Security and collaboration features give IT teams more control over the tagging process, while features like auto-event triggers and built-in templates help marketers get the data they need without having to deal with code.


For scenarios where the built-in templates don’t cover your needs, we also offer options to deploy your own custom HTML and JavaScript. To help protect the security of your users and sites, we already scan all custom HTML tags for malware. Developers can also choose to blacklist custom scripts directly on page. But, we want to help make tagging even safer.


Today, we’re introducing Custom Templates—a new set of features in Tag Manager and Tag Manager 360 to give you more transparency and control over the tags on your site.


With Custom Templates, you can use a built-in Template Editor to design tag and variable templates that can be used throughout your container.

custom gtm animation

This means that less technical users can manage instances of your custom tags just like the built-in tags, without messing with code. (Custom Templates will show up alongside the built-in templates when you go to add a new tag or variable.) And, since you can write your template once and reuse it, less code will need to be loaded on your site.

Template permissions


In order to provide a safer execution environment for your tags, Custom Templates use a sandboxed version of JavaScript. With sandboxed JavaScript, certain potentially sensitive operations (e.g. loading external scripts, accessing cookies, sending pixels, etc.) require the use of sandbox APIs:


Custom GTM Code

When you use these APIs, associated template permissions will automatically be surfaced and require that you declare how you’re using them (e.g. where external scripts can be loaded from, which cookies can be accessed, where data can be sent, etc.):

Custom GTM Perms

The behavior of your templates is tightly controlled by these permissions. Other users will be able to see exactly what your custom tags and variables are permitted to do. And, developers can write on-page policies to govern their behavior.


Starting today, you’ll see a new Templates section in the left sidebar of your containers. Whether you’re a marketer wanting to do more in Tag Manager without code or a developer wanting more control over third-party tags on your site, Custom Templates will improve your tagging capabilities.


Visit our developer documentation to learn more about Custom Templates, sandboxed Javascript, and permissions.