There’s a long list of reasons that make using Google Tag Manager (GTM) essential in digital marketing: but the single most important one is that consolidating all of your scripts into one specific place is a huge advantage these days.

  • If you’re part of a smaller company you may not have much (or any) engineering resources to push your tracking code to your site.
  • If you’re working at a larger company, pushing a simple script to production can be costly, dangerous, and annoying to the engineers.

Getting Google Tag manager installed allows you to easily consolidate and push all of your marketing tools’ scripts safely, using a friendly user interface.

In this blog post, you will be learning exactly how to add Google Tag Manager to your WordPress site, which should only take about 5 to 10 minutes.

So let’s get going.

Here’s the quick high-level overview of everything we’re going to do next.

  • The goal: To add Google Tag Manager to a WordPress site.
  • The ideal outcome: Google Tag Manager is properly installed and there’s no technical issues.
  • Prerequisites: This specific method is only applicable to WordPress.org installations, so anything on WordPress.com is not going to work, but if you’ve installed WordPress onto your own domain, you should be fine.
  • The importance of this action: As an internet marketer, Google Tag Manager is the single place where you should be putting all of your tracking pixels because it allows you to easily manage all your tools, pixels, and code in one centralized spot while allowing you to preview your additions before pushing to production, and to revert to previous versions very easily in case something goes wrong.
  • Where this is done: This will be done in both your WordPress back-end and in Google Tag Manager.
  • When this is done: Only once. You only have to install Google Tag Manager one time, and then you’re set going forward.
  • Who does this: The person who is managing your website or your analytics, anyone running paid campaigns, your web developer, or maybe just you.

Get This Entire Walkthrough and All the Resources in This Post

Environment Setup for Adding Google Tag Manager

Before you move on to the actual setup of Google Tag Manager:

  1. Install the Google Tag Assistant Chrome Extension. This tool is extremely helpful not just for Google Tag Manager setups, but also to debug many other tracking tools.
Installing Tag Assistant (Chrome)
  1. Sign up for a new account on Google Tag Manager if you haven’t done this already:

a) If this is your first time creating a Google Tag Manager account, you will be prompted to set one up.

Sign up for Google Tag Manager

b) For now, you can enter your company’s website and the company name for both the account and the container name. In our case, this was http://www.asiteaboutemojis.com/, our testing ground.

c) Select your country.

d) Click “Continue”.

Add a new GTM account

e) Enter the container name (the actual website).
f) Under “Where to Use Container”, select “Web”.

using a GTM container

g) Accept the terms of service – read them if you want, but the short version is that you sign your life away to Google.

GTM terms of service agreement
  1. Once you have set up your Google Tag Manager, the platform will give you two codes. There are two methods you can use at this point:

a) Do as instructed on the page:

  • The first GTM code: they will ask you to take it and paste it as high in the <head> section of your HTML as possible. You should do this for all of your site’s pages.
  • The second GTM code: they will ask you to paste this immediately after the opening of the <body> tag.
Install GTM script
  • Remember, if you are hand-coding or hand-designing your site, and if you want to paste the code in there, you can definitely do this – but otherwise, specially if you are using WordPress, we have an easier method, as shown below.

b) Don’t do as instructed on this page, and follow this easier method (only for WordPress) instead:

i. Hit the “OK” button without doing anything with the codes they offer you when you first sign up for Google Tag Manager.

Install GTM The Easy Way

ii. When you open your Google Tag Manager dashboard, the first thing you see is your Google Tag Manager ID (up top). Right click and copy that into a note to have it later on, when you install Google Tag Manager on your WordPress website.

Install GTM The Easy Way Screen 2

iii. Click on the “Submit” button at the top right-hand corner.

submitting a container

iv. The pop-up on the screen will allow you to add Version Names and Version Descriptions of the Google Tag Manager containers. This will useful in the future when you will want to push other Google Tag Manager containers – but for now, you can leave it as it is.

changing version names in GTM

v. Click the “Publish” button at the top of the page to push the GTM container.

submitting changes in GTM

vi. Skip the description and click “Continue”. Your Google Tag Manager is now live.

Container version description

Adding Google Tag Manager to Your WordPress Website

Now that you’ve set up the Google Tag Manager account and published your first container, it’s time to set it all up in WordPress as well. To do this, you will have to install a WordPress plugin, and then edit the custom HTML theme a bit.

  1. Go to your WordPress Dashboard.
  2. Go to Plugins → Add New.
Adding a new plugin in WP
  1. Go to the search bar in the upper right-hand side of the screen, under “keyword”, and search “Google Tag Manager”.
Finding the Google Tag Manager in your WP plugin directory
  1. You will see a lot of options available there, a lot of which work. However, the easiest one and the one I’m going to show you today is usually the first one that shows up. It’s called “DuracellTomi’s Google Tag Manager for WordPress”.
  2. Click “Install now”.
Installing Duracell Tomy's GTM plugin
  1. Once installed, click “Activate”.
Activating Google Tag Manager for Wordpress
  1. Go to settings down, on the left-hand side, click on “Google Tag Manager”.
Finding Google Tag Manager in Wordpress Settings
  1. Paste the Google Manager ID you copied from your Google Manager Account earlier on.
Google Tag Manager ID
  1. Leave the “Container code placement” to its default, “Custom”.
  2. Click “Save Changes”.
GTM Container code placement
  1. You will have to tweak your WordPress template just a little bit in order to get this to go. This is a one-time thing and once you make it work, you can add and remove pixels ad nauseam, forever and ever.

a) Copy the php code they show right above the “Save Changes” button.

customizing WP template to place GTM code

b) In the WordPress sidebar, go to “Appearance” → “Editor”.

editor settings wordpress template

c) Make sure you’re editing the theme that you currently have installed in your site. Everyone’s theme is going to look a little bit different, but I’ll show you the way to do it that should apply to most WordPress websites.
d) Select “Theme Header” from the list on the right. If you can’t find the “Theme Header” in the list, use CTRL+F (Windows keyboards) or Command+F (Mac keyboards) to look for your “header.php” file.

Theme Header php

e) Find the body tag – it’s usually near the top. Again, if you can’t find it, press CTRL+F or Command+F and search for “<body”.

finding the php body_class in wordpress

f) Hit Enter right after thetag.
g) Paste the little snippet of php code that the Google Tag Manager plugin gave you before.

gtm tag - pixel

h) Scroll down and click “Update File”.

updating theme file

QA the Google Tag Manager Installation

Now that you have set up Google Tag Manager and installed it to your WordPress website, it’s time to QA the entire process:

  1. Go to your website.
  2. Click on the Google Tag Assistant Chrome Plugin you installed earlier.
QA test your gtm installation
  1. Leave all the default settings there.
  2. Click “Done”.
QA testing your GTM installation - done
  1. Click “Enable”.
QA testing GTM installation - 3
  1. Reload the page and you will see that Google Tag Manager is working.
Enabling GTM

Double Conversions With Laser-Focused Google Analytics

Get the 2018 Ultimate Guide to Perfect Google Analytics Tracking sent to your inbox.

152 Shares
Share152
Tweet
Share