**This article has been updated in January, 2021 to reflect the change that replaced Preview Mode with Tag Assistant. For familiarity’s sake, this post shows how to install the Google Analytics 3 (Universal Analytics) tag. Once GA4 becomes more ubiquitous, we will update this article again to install GA4 via GTM.
Everyone has already told you that Google Tag Manager will make your life easier, but how do you get it on your site? Luckily it's very easy to install Google Tag Manager (GTM). We'll discuss how to set up your Google Tag Manager account, install GTM on your site, and adding & publishing the Google Analytics Universal Analytics tag.
Setting Up Your Google Tag Manager Account
Go to Google Tag Manager and make sure that you're signed into the Google Account that you want to use (or create a new one here).
Click the Create Account button to create a new account
Fill in the appropriate information for Account Name and Container Name; select the Target platform (Web if this is for your website) and click the Create button
Read and accept the Google Tag Manager Terms of Service Agreement. At this time It is also advisable to check "I also accept the Data Processing Terms as required by GDPR."
Installing Google Tag Manager to your Site
After creating the account and container, you will immediately be greeted with a prompt to copy & paste some code onto your site. Follow the instructions and paste the code from the top window as high in the <head> as possible on every page of the website. Next, paste the code from the second window immediately after the opening <body> tag.
A couple of words to the wise…
DO NOT SEND THIS CODE IN THE BODY OF AN EMAIL!
DO NOT SEND THIS CODE AS A MS WORD ATTACHMENT!
If you must email this code to someone else, paste it into Notepad and save as a Text (.txt) file before attaching to email. Sending in the body of an email or in a Word document may result in formatting that breaks the code.
Google Tag Manager and your Content Management System
Since we are well-past the Web 1.0 era of static websites, chances are that your site is built on a Content Management System (CMS). The process for installing GTM to your CMS may vary, but in most cases the process is straightforward. In many cases, your CMS may have an easy integration with Google Tag Manager, and you only need to copy the container ID (looks like GTM-XXXXXXX) into your CMS to get started. See below for some helpful links on installing GTM on popular CMS platforms:
Installing the Google Analytics tag to your GTM container
Now that Google Tag Manager is installed on the site, let's install your first tag. I'll assume that you already have created your Google Analytics account, or you are using an account that already exists. If you still need to create your account, go to Google Analytics create your account before proceeding.
In your Google Analytics Account, click Admin at the bottom of the left-hand-side panel.
Then click Tracking Info >> Tracking Code and copy the Tracking ID that you see on the screen. It will look something like UA-123456789-1.
Go back to your Google Tag Manager window. We now need to create the Google Analytics Settings variable using this tracking ID. To do so, click Variables on the left-hand-side panel, and then the New button in the User-Defined Variables box.
Next, give the variable a unique name like GA Settings, and then click inside the Variable Configuration box to select the variable type. After you do so, a panel with a list of different variable types will show up on the right side of the screen. About 3/4 of the way down this list will be Google Analytics Settings.
Click on it. Then input your Tracking ID that you just copied from Google Analytics. Then click Save.
Next, we must create the Google Analytics Tag. On the left-hand-side panel, click Tags, and then click the New button.
Give this tag a unique name like GA Universal Page View, and then click the Tag Configuration box to select the tag type. Next select the Google Analytics: Universal Analytics tag which should be the first option in the right panel.
Leave the Track Type as Page View. In the second drop-down menu, select the variable that you just created.
Next, we'll need to apply a trigger to tell this tag when to fire. Since this is our universal page view tag that should appear on all pages, we will select the default All Pages trigger that is already created in your GTM account.
Now our tag should look like the below. Click Save.
Tag Assistant (Formerly Preview Mode) - Your Bestest Friend in the Whole World
Almost there! It's always a good idea whenever adding a tag to verify that the tag is firing before publishing it to the live website. A 2020 update has changed (for the better) how we QA our tags. We perform this QA by using what is known as Tag Assistant. Tag Assistant records the entire session across pages instead of showing you what happens individually on the current page. To enable Tag Assistant, simply click the Preview button near the top right of the page in GTM.
Next, a new browser tab will open, and you will be prompted to enter a URL. Enter the URL where you would like to QA your tag(s), and click the Start button. You should also leave the box checked that says "Include debug signal in the URL" unless adding this parameter would break your website.
In a third tab, you'll be taken to the page that you entered. You will notice that gtm_debug=x has been appended to your URL if you left the box checked in Tag Assistant.
Also you'll notice that there is a message that pops up in the bottom-right of your browser window that says "Debugger connected."
Now you are ready to verify that tags are firing. Back in the Tag Assistant tab, you should see a panel taking up the majority of your window. In that panel, you should see a summary of the tags that have been fired on this page, and the tags that have not been fired on this page. Since we configured the GA Universal Page View tag to fire on all pages, this tag should appear under the Tags Fired On This Page section.
To further verify that it is firing on all pages (and that GTM is installed on all pages), go back to the tab with your site and navigate through a handful of pages. After going to a few pages, go back to Tag Assistant and confirm that the tag appears in the "Tags Fired" section for each page. Seeing activity for each page is as easy as clicking on the page title as it appears on the left-hand side of Tag Assistant.
NOTE - after you're done QAing your tags, don't forget to exit Tag Assistant by clicking the X at the top-left of the window and then clicking "STOP DEBUGGING."
After you've verified that GTM is installed, and your Universal Analytics tag is firing properly, it is time to take a deep breath and publish to the live container on the website. To do this, click the Submit button near the top right of the page.
Then enter a name and description summarizing the changes you made, and click Publish.
That's it! Now that you've installed Google Tag Manager and deployed the Google Analytics Universal Page View tag, you're able to see data populating in your Google Analytics account when users begin visiting your site.
You now also have the ability to add more tags, triggers, and variables. Google Tag Manager is a very powerful platform, and once you understand how it works, you can use it for so much more than just adding the GA Page View tag to your site. Our team has been installing and customizing GTM for years and can help you take your site tracking to the next level.