I’ve received a lot of questions about Google Tag Manager over the past 6 months or so; questions from co-workers, clients, and even creepy strangers. I thought I’d answer some of the more common ones here, in a blog post, to help clear the air.
Google Tag Manager – or GTM, as I affectionately call it – is an empty container or container snippet that can contain other tags you are currently using or would like to use on your site. Some examples of tags or scripts that you can use in GTM are:
Before we get too far into that, we should probably take a step back to get an overview of all the different parts. GTM works much like Google Analytics in that there are hierarchies you must keep in mind:
You must have or create a Google Account to access GTM. When you login to Google Tag Manager for the first time, you’ll arrive at the Overview page. The Overview page lists all the different accounts associated with the GTM account. If you are in-house, you likely only need a single account. However, if you work for an agency, it’s probably best to set up an individual account for each client. This way you can grant access to people who might want to poke around without giving them access to accounts they shouldn’t be able to see.
The container or container snippet is essentially what GTM consists of in terms of implementation. Here’s an example of what the script looks like:
<!-- Google Tag Manager -->
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s),
<!-- End Google Tag Manager -->
You can find this code under “Settings” below the “Users & Settings” tab.
Technically you are supposed to put this snippet at the top of the <body>, but depending on the tags you place within it, it can operate functionally within the <head>. The reason I say depending on the tags you place within it is because certain tags require the page to finish loading before they can fire.
Google Analytics on the other hand works asynchronously (it loads separately from the rest of the elements on the page). You want it to be one of the first scripts fired on the page to be able to properly track visitors that bounce/exit. You want to use the same container snippet throughout every page. The real beauty of GTM comes in the next level down.
The tag can be your Google Analytics, it can be your conversion tracking pixel, whatever your heart desires. Just be sure it’s not one of those tags that require the page to finish loading. Merely creating the tags is not enough. Next you need to dictate when the tag fires through conditional statements.
Rules are AWESOME! They can be as all-encompassing or as granular and super-selective as you’d like. Let’s say you have a template for the header of all pages — including your development site. You’ve got dozens of people crawling through your dev site, poking around, creating bogus data in your analytics. You would set up your rule to ignore that development environment, whatever it was set to.
This is an example of a rule to fire for any page the container resides on. That up there is a Regular Expression set to match any URL. The box all the way on the left allows you to select different Macros. As you can see in the above screenshot, the current URL is an example of a Macro. Macros can also be the hostname, the HTML element, the id, the class, a bunch more stuff that’s honestly beyond the scope of this post. Forget about that for now, let’s move on to the match conditions – you don’t have to use RegEx.
There are tons of options! Are you starting to get an idea of all the different ways this can be used? Let’s go into another example.
Let’s say you want to set up a rule for your AdWords conversion tracking code. You would set the container up in GTM and set up a rule to fire only on those confirmation page URLs.
Once your container is on every page on your site and all ready to go, you hit the publish button at the top of the screen, and you’re good to go!
Google Tag Manager is one sweet beast, but it might not be for everyone. We sure enjoy being able to cut down on implementation time and freeing up IT staff to deal with more important issues.
If you are thinking of upgrading your Google Analytics account, check out our ebook below! We’ll help you determine which tool will best fit the needs of your business.