How to Implement Google Analytics Tracking Code via Google Tag Manager

Grant Marlowe - December 16, 2015

Once you have added the Google Tag Manager (GTM) container code to every page of your website, the hard part is over! Now we can move on to the fun stuff: creating our very first tag. Nine times out of ten, your first tag will be the Google Analytics Tracking Code tag so that we can continue to monitor our website traffic – so this is the tag we are going to focus on for today’s post.

The great thing about GTM is its ease of use, Google Tag Manager makes it quick and easy for us to add different tags to our site, usually without requiring the IT team’s involvement. If we follow the step-by-step instructions laid out in the GTM interface, in no time we will have created several tags and added them to our website.

Let’s start out with our first tag, the Google Analytics Tracking Code (GATC) tag. Once you have logged into GTM and accessed your account, click the “Add a new tag” link that is positioned towards the top left of your page.

add new tag
From here we need to do two things. First we need to create a name for our tag. I usually start all my tags with the name of the product type we are going to be using, followed by a dash and then the actual tag type we are creating. So in this case, the syntax for our tag might look something like “Google Analytics – UA Tag.”

The next thing we need to do is choose our product type. Select the Google Analytics option in the top left, and then we can hit “Continue” to proceed to the next step.
select ua tagOnce we hit continue, the next step is to choose a tag type. Select the option for “Universal Analytics.” This is Google’s latest version of tracking code, which among other benefits, allows you to collect data from any digital device. Hit continue and this should take you to the 3rd step: configuring our tag.

This is the step that makes our GA tag unique compared to everyone else’s. Step 3 asks for our Tracking ID – this is the numeric tracking code that Google assigns to every newly created account which is specific to your web property (an example would be something like: UA-12345678-9). If you don’t know where to locate your unique tracking ID, you can open your Google Analytics account and in the Admin section, under the Property Column, look for the “Tracking Info” tab, then click on “Tracking Code.” Here you should see your unique Tracking ID displayed at the top of the screen. Copy the entire ID and re-open your GTM window.

Now we can paste our tracking ID in the proper field, and we can leave the “Track Type” drop down set on “Page View” then hit the blue “Continue” button.
tag type
Another option when assigning the tracking code ID is to create a “Constant Variable” in Google Tag Manager. This is a slightly more advanced method but offers the benefit of not requiring you to re-enter your GATC every time you create a new tag. You create your Constant Variable, add the unique tracking ID one time, and then anytime you need your ID in the future, you do not need to go fetch the GATC, and you can use the Constant Variable instead!

Now, the first 3 steps of this process are for building our tag, the fourth and final step in the process is for creating the Trigger that will communicate with our tag when it should fire (“fire” is the term GTM uses to define when the tag should send information to the Google Analytics servers). Every scenario will call for different Trigger instructions, some more complex than others, but for our tag we will want it to fire on “All Pages” so that we can track a visitor’s behavior across every page of our site. Once you select the “All Pages” button it will appear right below in green.

all pagesThis tells us we have defined the Trigger that should be used when our Google Analytics tag will fire and we are now ready to hit “Create Tag” and complete our tag configuration!

It is important to remember that just because we have created a tag, this does NOT mean it will begin tracking automatically. When you are satisfied with the tag configuration, you must hit the red “Publish” button located in the top right of your screen. This will push whatever tags you have created “live” and these will now begin to fire data into your GA account.
publish
A useful tool that comes built into GTM is the “Preview Mode” view. As your tags become more complex, this is a great way to “test” your tags to make sure they are firing as intended before pushing them live. For this we can use the Preview Mode to test out the tags we have created by simply going to our website and seeing that the bottom portion of the browser has now opened a GTM preview pane. Use this to confirm that the tags you created are firing correctly before you publish them live.

We have now created our first GTM tag and hopefully you have a general understanding of the tag setup process. Take a look at some of the other pre-made tags GTM has available and experiment with different firing rules and triggers. Google Tag Manager is a great tool which allows us to really leverage our web properties in order to gain valuable insights about our visitor traffic!

© 2023 MoreVisibility. All rights reserved.