Getting started with Google Tag Manager

Google Tag Manager allows you to conveniently manage tags (such as tracking and marketing optimization JavaScript tags) on your site. You can add and update AdWords, Google Analytics, Floodlight and non-Google tags from the Google Tag Manager user interface instead of editing site code. This reduces errors, frees you from having to involve a webmaster, and allows you to quickly deploy tags on your site.

The Google Tag Manager container snippet is a small piece of JavaScript and non-JavaScript code that you paste into your pages. It enables Tag Manager to fire tags by insertinggtm.js into the page (or through the use of an iframe when JavaScript isn’t available).

To implement Google Tag Manager, copy the code snippet provided in the Tag Manager interface or from below, replacing both instances of GTM-XXXX with your container ID. Paste this snippet into your website template page so that it appears immediately after the opening <body> tag.

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<strong>GTM-XXXX</strong>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<strong>GTM-XXXX</strong>');</script>
<!-- End Google Tag Manager -->

Many tag management operations can be achieved by just doing the basic code installation, but if you’d like to have finer grain control over tag events or data, you may want to use some customization using our asynchronous methods.

To ensure maximum flexibility, portability, and ease of implementation, Google Tag Manager functions best when deployed alongside a data layer. A data layer is an object that contains all of the information that you want to pass to Google Tag Manager. Information such as events or variables can be passed to Google Tag Manager via the data layer, and rules can be set up in Google Tag Manager based on the values of variables (e.g. fire a remarketing tag when purchase_total > $100) or based on the specific events. Variable values can also be passed through to other tags (e.g. pass purchase_total into the value field of a tag).

Rather than referencing variables, transaction information, page categories, and other important signals scattered throughout your page, Google Tag Manager is designed to easily reference information that you put in this data layer. However, explicitly declaring the data layer is optional and if you choose not to implement the data layer, you can still access values from the page using the the Macros feature, but you cannot use events without the data layer. Implementing the data layer with variables and associated values, as opposed to waiting for those variables to load throughout the page, ensures that they will be available as soon as you need them to fire tags. (Google Tag Manager DataLayer Implmentation details)

For more information about the features and benefits of Google Tag Manager:

After you setup your tags you can use Google’s Tag assistant to verify them. Google tag assistant monitors all the Google tags (DoubleClick, Analytics, Adwords etc) on the active page and alerts you if any of them is not working right. The tag assistant is a Google Chrome extension that can be installed here.

Panagiotis

Written By

Panagiotis (pronounced Panayotis) is a passionate G(r)eek with experience in digital analytics projects and website implementation. Fan of clear and effective processes, automation of tasks and problem-solving technical hacks. Hands-on experience with projects ranging from small to enterprise-level companies, starting from the communication with the customers and ending with the transformation of business requirements to the final deliverable.