Google Tag Manager Basics #2: A Closer Look At GTM
This is the second of a series dedicated to introducing you, faithful reader, to the wonders and delights of Google Tag Manager. Last time, we were looking at just what a tag manager is anyway? This time, we’ll be taking a look at GTM itself.
We’re going to go through the three key components of GTM: tags, triggers and variables. We’re not going to touch on the other things in the GTM sidebar, folders and templates, for the time being—they’re useful extensions but not truly core functionality in the way that these three are.
We’ll start with tags, since they’re in the name—they’re the components within GTM that send information to outside providers. You have tags to send information to Google Analytics or Doubleclick or whoever you want—or, if you’d like, to change things on the site.
Tags are just blocks of code; and in GTM they come in two varieties— templated and custom. Templated tags are provider-specific, and quite straightforward–you just fill in the boxes! They’re a “friendly face” so that you don’t have to deal directly with code. Custom tags are blank canvases, and powerful—you can do pretty much whatever you want with them! You can use them to add tags from providers who don’t have templates—e.g. Facebook—or make changes to the site code itself¹.
A lot of the information they send is provided by variables, which retrieve information either from the GTM itself, from the site or from the data layer.
Variables are little units of data, the icon for which looks like a Lego brick, which I personally think is delightful. They can return values about the page (its URL, for instance), or if you interact with something on the page—click on a link, say—return values about the element you interacted with (its URL or text). They can do all sorts of other things too—and we’ll examine them as we get further into GTM.
Variables are also used by triggers to determine when the tags should fire. There are a number of different types of trigger, based on all the different sorts of user interaction that GTM can listen out for—page view, link clicks, form submission etc. Then within that, you can specify additional conditions—this trigger will fire any tags attached to it when this event happens, provided this variable meets these conditions. For example, a link click trigger might only fire when the url being clicked on has a different hostname to the site hostname, and hence is outbound.
This was a quick overview of the different components of GTM. They might seem somewhat abstract, but once you start using the tool, they’ll begin to become more concrete. Next time, we’ll be looking at creating a simple tag in GTM! If you have any questions, please get in touch 🙂
¹: Since the addition of templates, it’s now not necessary to run a lot of more common tags without providers as custom tags, as the community template gallery provides templates for many common but previously un-templated tags!