Predefined and custom GTM templates

Last year Google Tag Manager released a new feature called "Templates", which lets you build your own tag templates or pick from predefined ones.

Jakub Gombár

Jakub Gombár

AI Team Leader & Co-Founder

1. April 2020

3 min

Advanced

Last year Google Tag Manager released a new feature called "Templates", which lets you build your own tag templates or pick from predefined ones. It is a marked step forward in using GTM. This set of features helps make creating tags simple and clearer still. Custom templates can be built with JavaScript and HTML, while taking care that the code is well optimised in the browser. In this post we will look at the predefined templates.

Contents

Templates in brief

Custom templates are tag templates you can either build and configure yourself or pick from predefined ones uploaded to the gallery by other users. These are mainly third-party measurement templates such as the Facebook Pixel, Hotjar and so on, where HTML is used.

Comparison of a Facebook Pixel added via Custom HTML versus a template in GTM

The UI alone is a large difference. Being able to adjust something immediately, without hunting through code, minimises problems during setup.

Templates have another, less visible but important function. In short, Google checks whether the templates contain any malicious software.

Predefined templates

These templates are found under the "Templates" tab, where we then choose "Search Gallery".

Google Tag Manager – Templates tab and Search Gallery button for tag templates

Here is the selection of templates that can be added from the official Google Templates site. At our agency we use the templates for Adform, AppNexus, Facebook Pixel, Glami, Shopalike and Reddit most.

When we choose a template to add, Facebook for instance, Google warns us that the template injects third-party scripts.

GTM – warning that the template injects potentially unsafe third-party scripts

These templates can then be edited. In many cases it is no longer worth it, though, since they are very well tuned.

Setting up the Facebook Pixel with templates

First we find Simo Ahava's Facebook Pixel in the gallery.

Google Tag Manager – opening the template gallery with the Search Gallery button

GTM template gallery – searching for the Facebook Pixel template by Simo Ahava

GTM – Facebook Pixel template details and the Add to workspace button

Then we go to the Tags tab. We create a new tag and choose Facebook Pixel from the "Custom" section.

GTM – choosing the Facebook Pixel tag type in the Custom section when creating a tag

We add the Facebook Pixel ID and choose which event we want to send. There are three options:

  • Standard – sending standard events per the Facebook documentation
  • Custom – sending your own events
  • Variable – sending GTM variables

There is also a "Consent Granted (GDPR)" field. The point is that if it is set to "False", the pixel will send no information until a tag fires where "Consent Granted" is set to "True". You can read more about this field here.

If we tick the "Enable Advanced Matching" checkbox we can send parameters such as city, date of birth, email address and so on — from forms, for instance. The "Enable User Properties" checkbox means we will send a User ID, which has to be in the format given in this documentation.

Under "More Settings" we find the option to disable automatic configuration. It means Facebook automatically gathers certain metadata, such as user interactions. Ticking it disables the pixel's automatic configuration.

The last tab, "Advanced Settings", holds the advanced settings every tag in GTM has.

I chose the predefined ViewContent event. When we want to send event parameters too, we open "Object Properties". Here we can choose whether the data should be pulled from a variable (if we were sending all the information into a single variable), or leave it "False" and click "Add property", where we can add variables for the ViewContent event.

 

The parameters would then look like this:

GTM – Facebook Pixel parameters mapped to product dataLayer variables

In the end the pixel might look like this:

GTM – finished Facebook Pixel tag configuration with the ViewContent event

I trust this article has helped you understand templates in GTM. Using templates rather than HTML has the large advantage of minimising the risk of errors when copying and editing code. It also makes setting up conversion tracking easier and simpler for many people.

Recommended reading

The latest trends, proven practices and analyses from the digital world. Find out how to take your technology and marketing growth further.