Tag management, and Google Tag Manager, exist to make web analytics implementations easier. If you’ve got a fairly simple site then you should consider using Google Tag Manager to implement Google Analytics. It greatly simplifies the process.
The Standard Google Analytics Tag Implementation
Let’s Walk through a very basic Google Analytics setup using Google Tag Manager. Here’s a video if you don’t want to read :)
I’ve got a small site that used to sell my old e-book. I want to implement the standard Google Analytics tracking code on this site using GTM.
The first thing I need to do is create a container. The container will hold my Google Analytics tag along with any other tags that I may wish to put on the site.
There’s not too much involved in creating a container. You need to name the container and choose a timezone.
I should mention that Adding a domain to the container is not necessary. It just triggers various help in the user interface. While not necessary I recommend adding a domain.
Once the container has been created it’s time to add the container JavaScript to the site. Copy the code and place it after the opening
tag on your site.Great, now we’ve got a container and it’s time to populate the container with our Google Analytics tag. The GTM team made it easy to install Google Analytics by creating a form for most of the GA tag options, as shown below:
For a simple implementation all you need to enter is the web property ID. This is the UA number. You can find it in your Google Analytics account.
Note: Google Tag Manager currently supports only the basic Google Analytics tag. Future releases of Google Tag Manager will allow you to customize your Google Analytics tag.
Next you need to specify the rules associated with your Google Analytics tag. The rules control which pages the Google Analytics tag will appear on. To learn more about rules see this post about understanding Google Tag Manager.
For this implementation we want to add the Google Analytics tag to appear, or fire, on every single page. We can use a default rule that meet this condition.
Once you click Save GTM will save the tag in the container BUT the tag will not be pushed live to your site. You still need to publish the tag. And you should also Preview the tag before publishing, just to make sure it works right.
If you’re interested in learning more about the tag preview and publishing process check out my post on understanding how to preview and publish with Google Tag Manager.
A lot of you are probably thinking about more complex implementations, like those that require cross domain tracking. Right now a lot of those choices are not supported with the standard Google Tag Manager – Google Analytics integration.
But there is another way to implement Google Analytics with Google Tag Manager.
The Generic HTML Tag Method
If you have a more complex implementation, you can use the Generic HTML Tag for the implementation. This type of GTM tag is basically arbitrary HTML. You can put anything you want in this tag. This includes the Google Analytics tracking code and any customizations that you want to include.
As you can see, you can put the GA tag in the basic HTML tag, with any customizations that you want.
Is it more work than using the standard GTM GA tag? Maybe a little. But if you want to switch to Google Tag Manager ASAP, and you have a complex implementation, then this is the method for you.
Hi,
Are you sure about Google Tag Manager not supporting cross domain tracking? – I think that if you add your different domains within the same container, the cross domain tracking might be automated.
Best regards,
Søren Larsen Pedersen
Web developer at Marketing Lion
@Soren: I’m sure. The Domain setting during the container creation is just for Preview mode. But I know that’s a feature that Google want’s to add. Cross domain tracking is something that needs to be simplified.
@Justin: I just saw Empirical Path saying: “During the certification process, Empirical Path consultants found some specific capabilities that we know we’ll use for clients: […] Simply insert the Google Tag Manager container code on each page and never have to implement cross-domain tracking again!”
Source: http://www.empiricalpath.com/empirical-blog/19-web-analytics/196-google-selects-us-to-support-new-tag-manager
@Soren: please let me look into whether we were getting ahead of ourselves…
Our mistake, sorry about that. We got our wires crossed after looking at all the tag mgmt solutions and knowing the cross-domain pain point! Updating blog shortly…
Any idea how to implement GA ecommerce tracking using GTM? IMO it may be possible using macros
@ Tomáš: Yup, I have a couple of ideas. It requires a little bit of JS, but you can do it. First, you need to put your transactional data some place where GTM can access it, like the data layer. Then you need to pull it out of the data layer and put it into the ecommerce tag. For this, try using a custom HTML tag that references the ecommerce parts of the data layer. I don’t think a macro would help here. Macros are for holding data that is in the data layer, then referencing them in Rules.
I like your thinking :)
Just wanted to ask something. Google Tag Manager does not seem to support codes that interacts with the content on the website. Services that convert keywords into ad links and so on. Is that right?
@Sushubh: If I remember correctly, those service usually rely on some JavaScript. You have to place their JS library on your site and then their JS converts keywords to links. You can certainly host that third party JS using Google Tag Manager. Just use a Custom HTML tag.
I saw this because it did not work for me. Even the New Tag page has this message:
Custom HTML can be used to include any tag that doesn’t need to make visible changes to the page (visible changes include tags with ‘document.write’ functionality built into the snippet, or any A/B testing tag, so please don’t use them).
great posts – tag manager is my new favourite !
I just wonder, does Google Analytics code implemented by Google Tag Manager cooperate with Content Experiments tag?
or in second option is it possible to implement both Content Experiments code and then Google Analytics code in one custom tag?
@Christopher: Great question. As of right now, you can not implement Content Experiments with Google Tag Manager because the Content Experiments tag needs to be at the top of the page. The container tag is placed after the opening < BODY > tag.
Justin
Any ETA on support for experiments and tag manager?
@Chris: Sometime after today :)
@Justin: great post, specially the generic HTML Tag steps. Just wanted to share that I’m currently running a GACE experiment by having both the GACE script placed in the header and the GATC fired from the GTM container script and it works perfectly fine. So this is indeed a possible workaround as Christopher might have suggested in his first point.
Thanks for the informative posts. One thing I haven’t been able to find yet is if there is a usage limit for GMT. Is there something similar to GA Standard’s 10 million monthly pageviews?
@Robert: No, there are no limits. Primarily because GTM does not collect any data. It just pushes out tags.
Excellent primer. Thank you, Justin! Good point about the need for publishing.
Just saw the tag manager mentioned in today’s video from Distilled, so I searched it and landed here. Great description of how exactly to use this new tool. I will use it as a reference when starting out with the tool.
It took me a while to figure out how to use dataLayer with onclick events with GTM and GA but once it is in place it’s a breeze to use.
About Content Experiments tags: I would like to do A/B testing with landing pages. Can I use GTM to deploy the tags required for this?
No, unfortunately GTM does not support testing, or any other tags that use the document.write. But that is a very requested feature. Thanks for the comment.