One of the most frustrating experiences early in my SEO career was setting up Google Tag Manager for a client’s website.
Google designed their Tag Management System (TMS) with ease-of-use in mind, and once I got used to using it, the system was pretty straightforward. But when I first attempted to track events and integrate GTM with Google Analytics, I hit a wall. Something wasn’t working.
I scoured the internet for answers, but nothing really helped. The GTM support provided by Google was a little clunky, and had a bit of a learning curve. Most blogs that detailed the process of how to link GTM and GA were trying to sell me on another TMS, skipped key steps in the process, or ended their guide without explaining how to view your results in Google Analytics.
So, to save you some time and frustration, here is a step-by-step guide on how to set up and link Google Tag Manager to Google Analytics.
Now, if you’re really new to SEO, here’s some background.
Google Tag Manager (GTM) is the easiest free way to track events on your website. If you’re not savvy with coding, or you’re afraid of cluttering your website with extra lines of code, GTM is your saving grace. And honestly, even if you are some coding wizard, GTM keeps all of your tracking organized and easy to monitor, so it’s generally preferred to manual tracking.
I assume you’re already at least a little familiar with Google Analytics. If not, here’s Google’s guide to get started. If you’re already working in Tag Manager, feel free to skip this next step.
Setting Up Google Tag Manager
Once you’re all set up with Analytics, open up a new tab and type in “Google Tag Manager”.
Click the first link. You’ll see this page, but with your face, not mine in the top corner.
Go ahead and click anywhere on the “Account” card, or the blue “Create Account” button in the top right corner. On the screen that appears, type in your company name like so.
Then, choose where you will be using GTM. I am tracking a website, so I’ve chosen web. After this, hit “create,” and accept the Terms of Service Agreement.
Now, you’ll see a pop-up like this.
This is your tracking code. Yours will look just like mine, except for your unique tracking ID, which is in the format GTM-XXXXXXX. If you accidentally click out of this bubble, don’t worry.
You can get this code whenever you need by clicking on “Admin” and “Install Google Tag Manager” under the “Container” column.
As Tag Manager explains, copy this first code. You’ll need to paste this into the <head> of the page. Here at ClearBox, we work with WordPress, which makes adding code like this to your site very simple. Rather than pasting this code manually on to every page of your site (which you will have to do if you don’t use a content management system like WordPress), you can auto-inject it.
Open up your WordPress site and go to your theme. I’m using Impreza. Under the theme, click “Theme Options” and then “Custom Code.” Here, you will paste your code. Paste the first code into “Code before </head>” and the second code into “Code before </body>.”
(As you can see, I’ve pasted both into “Code before </head>.” This doesn’t really make a difference with GTM’s functionality. I found that this way worked better for me, but follow Google’s recommendations first, and see how it works for you.)
Once this is done, hit “Save Changes.” Your tracking code is officially installed.
Creating a Tag
Now that Tag Manager is all set up, it’s time to create your first tag. Go back into Tag Manager.
Your screen will look like this. Click on “Add a new tag.” We’ll start out with something simple here. We’re going to create a tag that tracks page views.
Try to keep your tag names consistent and straightforward. Let’s name this one “Pageviews.”
Click Tag Configuration and select Google Analytics – Universal Analytics.
Confirm that the Track Type is set to Page View (it usually defaults to this type.)
Under Google Analytics Settings, you will need to create a new variable for your Analytics account. This is how GTM will communicate with Analytics.
First, in a new tab, open up Analytics. You will need your Tracking ID, which is found by clicking the gear in the bottom left corner. Under the Property column, click on tracking info, and then tracking code. Your ID is here, in the UA-XXXXXXXX-X format. Copy this code.
Go back into Google Tag Manager, and paste your Tracking ID in the appropriate space, and make sure the variable type is Google Analytics Settings. I named my variable as my Tracking ID. You can call yours whatever you want, just as long as it makes sense to you.
Now, click into the bubble labeled “Triggering.” Here is where you will create triggers that tell your tags when to fire. Currently, there will only be one trigger, All Pages. Select this one.
From the Workspace menu, click on Preview in the top right corner. Your menu will change and display this message.
Now, in a new tab, open your website (or refresh it if it’s already open in your browser). You’ll see a box appear at the bottom of the screen.
Look at that! Your tag will appear in the summary under Tags Fired On This Page.
It’s official: You’ve set up your first tag!
Tracking this Data in Google Analytics
So you have your first tag up and running. Congrats!
Now comes the fun part. Google Tag Manager is capable of gathering information that Google Analytics cannot alone (unlike page views, which Google Analytics can track on its own). The first tag I set up for an actual client was a tag that tracks unique button clicks. Let’s take a look.
This is the tag I created to track the “Call Us” button.
Like with the tag you set up, this one is a Universal Analytics tag. This time, the Track Type is Event.
This should look different to you. Since the track type is different, there are new fields to fill out. Category, Action, and Label fields are important. You’ll need these in order to make sense of the data you get from Google Tag Manager when viewing it in Google Analytics.
I’ve set mine up in a way that works for me. There’s no right or wrong with how you categorize your tags, as long as it stays organized and makes sense. I’ve set the category to “Button,” the action to “Click,” and I’ve labeled this tag with the name of the button and the web page on which it appears. This way, I can differentiate between the “Call Us” buttons on other pages on the website. I left the value blank, since it doesn’t apply to this type of event.
This time, the trigger will be very different. First, set the trigger type to Click – All Elements. You’ll need to click the blue plus (+) button in the top right corner to find it. We don’t want this to fire on every click, so select Some Clicks. Now, we have to define what types of clicks will fire this trigger.
I want this trigger to fire only when someone clicks my “Call Us” button at the top of my page.
This is the only button that says “Call Us,” so I set the conditions to Click Text – Equals – Call Us. I also added a second condition, Page URL – Equals – https://mersonlaw.com/philadelphia-archdiocese-irrp-faq/. This way, this trigger will only fire when the “Call Us” button on the appropriate page is clicked.
I named this trigger the same name as the tag, since it is the only tag this trigger is used for.
Your conditions will be slightly different than mine, obviously.
Save this tag and test to confirm it’s working in Preview Mode.
Publish the changes, and exit Preview Mode.
Now, go back to Analytics. Click into Real-Time Reports. Preferably on a different device, open your webpage. You’ll see yourself in the Report. Hi!
Go to the Events page in the Reports and then click your button on your other device. Within a few seconds, a new Event will appear.
Congratulations! You’re now tracking events.
These events can be seen in the Event report under Behavior.
I like to select “Event Label” to see which individual buttons have been clicked (This is why it is important to have a system when entering the Category, Action, and Label fields when making the tag.) Now, you can easily view what events occur on your site! Not too bad, right?