Analytics are the lifeblood of digital marketing – by recording every interaction someone has with your website, you can gain valuable insights into what is working, what isn’t, and the behavioural patterns of your users. Google Tag Manager (GTM) has emerged as a great add on to Google Analytics as it allows you to implement more powerful tracking as well as managing other tags on your site such as Facebook advertising pixels.

Today, we’re going to walk you through installing and creating tags in Tag Manager for sites powered by WordPress.

What is Tag Manager?

Tag Manager is a tag management system that allows you to quickly and easily update tags and code snippets on your website or mobile app, such as those intended for traffic analysis and marketing optimization. Not only does this save you time versus manually adding, editing and removing tags and scripts in your site’s code, there are many different pre-built connections with third party apps such as AdWords, Bing Ads, and Twitter plus the ability to add custom code. One of our favourite things to track is how many times people click on external links leading away from our website. You can track this and much more with GTM.

Google Tag Manage New Account

Getting Started

The first step is to sign up for Tag Manager from your Google account. Once you’re in, you’ll need to set up your first account within Tag Manager. Create one account for each website that you’re managing.

Next, you’ll be asked to add a container to your account. The container is how Tag Manager lives on, and is able to make changes to, your website. Think of it like a bucket where you put your various tags and triggers. While you can add multiple containers if you wish, for now we’re just going to use the one. Name your container (you can use your domain name) and choose Web as where you’ll use it. Click on Create to continue, which will then show you the code to install GTM on your site. You can skip this step for the moment and go to the container workspace. This is where you’ll add your tags and triggers.

Tags vs Triggers

When it comes to tracking for Google Analytics (GA), tags are the information that you want sent to GA and triggers are the events that make it happen. One trigger might be “All Pages”, in which case the associated tag sends info to GA every time a page loads. Another trigger might be something like “any time a form with the class ‘commentform’ is submitted”, in which case the associated tag sends info to GA only when someone submits a particular form. For Analytics, your tags will generally be pageviews or events, though you can also track timing events, social interactions, and more.

Creating a Tag

New Google Tag Manager TagWe’ll walk you through setting up a basic Google Analytics pageview tracking tag. Click “New Tag” from the Workspace dashboard. Name your tag and then click in the ‘Tag Configuration’ to choose your tag type. For this example, choose Universal Analytics.

Tip: set up your Google Analytics ID as a constant variable to save yourself from typing it several times while setting up tags.

You’ll need your GA tracking ID, which is an identification code that you can find in the Admin tab of your Analytics account. Choose ‘Pageviews’ as the tracking type for this example. This will pass the basic page visit information on to Google Analytics for you, the same as your regular GA tracking code.

GTM Analytics Tracking

Next you’ll click in the ‘Triggering’ box to set up what will trigger this tag info to be sent to GA. For this example you want your pageview information to be sent every time a page loads so choose the default ‘All Pages’ trigger. If you need more specific event triggers, you can create a custom trigger by clicking on the + in the upper right corner. Common trigger types include ‘Just Clicks‘ and ‘Form Submission‘.

Click Save and there you go, your first GTM tag created. Before these will be live to starting tracking on your site you’ll need to publish your container and then add the code to your website.

Adding Google Tag Manager to Your WordPress Website

Now you need to add the Google Tag Manager script to your WordPress site. You’ll need to add code in two places and, if your theme doesn’t allow for custom code, the easiest way to do this is by using a plugin. We recommend Insert Headers and Footers. Install the plugin on your site then go to Settings / Insert Headers and Footers.

Go back to GTM and grab your code under Admin / Install Google Tag Manager. Copy the first block of code and paste it into the “Scripts in Header” section. Copy the second block of code and paste it into the “Scripts in Footer” section. Save your changes.

GTM Install Code

Don’t Double Up Your Tracking

It’s important to remember that once you have your Google Analytics tracking, Facebook pixel, etc. set up in GTM that you remove their own code from your site so that you don’t have duplicate tracking code, as this can cause data collection errors. Google Tag Manager is the only script you need to add to your site.

You can now continue to add new tags and triggers to your GTM container without needing to touch the code on your site. Simply make the changes in Google Tag Manager and publish your updated container.

If you run into any trouble or would like help with Google Tag Manager installation or creating tags, please reach out to us.

Website Scorecard