Google Tag Manager Custom Templates and Variables

May 27, 2019 - Written by

Few days ago Big G released at last two new super cool features, available for all accounts worldwide:

  • Custom Template
  • Custom Variables

Consider that I won’t go to deep into the tech side of the two features, since I think you can refer to Simo Ahava: at the end of the post you will find the links to his guide and other the useful resources to help you building the Custom Templates, together with an example of creation of the Custom Template for Facebook’s pixel.

As said above it makes no sense to replicate Simo’s guide: the main focus here is to highlight the potential of the new features.

Google Tag Manager Custom Templates

In a nutshell, we can say that the Custom Templates are the representation via UI of the custom HTML, but I would make a mistake. Not each custom HTML needs necessary to be a template.

Custom Templates have the following characteristics:

  • Safer execution environment as the code injected must be created through a Custom Javascript Framework using new APIs. No code can be executed via standard JS, but only via APIs. You can find the Official documentation linked among the resources at the end of the post.
  • Input, descriptive or error and help fields, and nested fields with different configurations can be added
  • The whole steps for the creation of a Custom Template can be checked using a dedicated consolle: a kind of preview, but a more technical tool.
  • Importing and exporting built-in templates is available in a dedicated section, as per single Container in Tag Manager

 A Custom Template creation allows to speed up routines we usually face daily. As an example a Custom Template can be dedicated to the Facebook Pixel: instead of replicating X times the same Custom HTML, where few elements change, we could create a Custom Template and make it available via UI.

Google Tag Manager Custom Variable Template

The Template Custom Variable differs from Template Tag because they only have to return a value.

Even in this case, the Custom Variable can replace a Custom HTML that features the creation of a recursive element. In order to create custom variables you also need to rely on the JS framework via APIs.


Below you can find the links to useful resources to further explore the new feature of Google Tag Manager:

After the launch of the Custom Templates we can expect that a kind of a Library/Repository will be made available, so that you can tap into the Tag/Variables that might be useful, as it happens for the Google data Studio connectors.

And what about you? What would you use Custom Templates for?


Leave a Reply

Your email address will not be published. Required fields are marked *

  • Analytics Boosters

    Vicolo Buranelli, 2
    31100 Treviso

  • Analytics Boosters
    United Kingdom

    41 Devonshire Street
    W1G 7AJ
    United Kingdom

  • Analytics Boosters
    United States

    80 S.W. 8th Street
    33130 - Miami
    United States of America


Contact us