The Complete Google Tag Manager Tutorial (8 Scripts in 1)

Google Tag Manager is a great free tool from Google that allows you to combine all of your tracking and analytic scripts into one management interface. This can be great for marketers who don’t have access to their website. This means they no longer have to work with IT or their webmaster to update their site and can focus on more important things. When I first heard about this my first question was, well how fast is it? I am always concerned with speed. The great news is that Google utilizes their own CDNs to push out your tags. So no need to worry there. There is a great article I recommend reading on ConversionXL about “How Tag Management Can Improve Site Performance.” This really has made my life so much easier and I definitely feel more organized. No longer do I have different scripts scattered all over the place.

How does Google Tag Manager work?

Google Tag Manager keeps track of a set of tags and tag-firing rules that define when those tags should be made available on your site. When a user visits the site, the most up-to-date tag configuration is sent over to the end-user’s browser with instructions for which tags should fire. Source: How Google Tag Manager Works (Web)

Please note: Even though I said 8 Scripts in 1, Google Tag Manager doesn’t actually reduce the number of pixels or scripts that your site fires, but it simplifies the task of managing those pixels. In addition, since the container snippet itself executes asynchronously, your pages are likely to load more quickly.

Once you use Google Tag Manager you never go back! Take the time and do it, trust me.

Google Tag Manager Tutorial Index

Click on one of the tutorials below to jump to that section.

Below I am going to show you how to setup Google Tag Manager and configure/deploy 8 different tracking scripts. These are simply the networks I am currently using. If I don’t touch on a network you are using some of the instructions below probably will work fine for you as well. You can always test it and find out.

How to Create Your Site in Google Tag Manager

Step 1

First you need to head over to https://www.google.com/tagmanager/ and create your free account.

Step 2

We will setup a name for our account and click “Next.”

setup account google tag manager

Step 3

Next you need to setup a container. For the container I recommend just using your domain name. For my site I am going to choose http:// because I don’t have an SSL cert on my site. You can either change it to https:// or you can select // which will work with both. Then I input my domain name and choose my time zone. Then click on “Create Account and Container.”

setup google tag manager container

Step 4

Then click on “Accept.”

accept agreement

Step 5

Now if you are working on a site other than WordPress you will need to copy the code and place it right after your opening <body> tag. Then click on “Add Tags Later.” If you are running on WordPress, write down/copy the GTM-XXXXXX number as we will be using this in the next tutorial.

container code

How to Setup Google Tag Manager in WordPress

Step 1

First we are going to install a WordPress plugin to implement the Google Tag Manager code. The reason we are using a plugin is because there is a great free one available with extra options which makes things easier. So in WordPress go to add plugins and search for “Google Tag Manager for WordPress” and install “DuracellTomi’s Google Tag Manager for WordPress” plugin.

duracelltomis google tag manager plugin

Step 2

Now you in the plugin you are going to enter in your GTM number from your Google Tag Manager container. Then there are two options, you can have the container code placed in the footer or place it yourself (custom). I recommend using custom because it is following Google’s recommendations to place it right after the opening <body> tag. Then press the “Save Changes” button.

google tag manager wp general

Step 3

So we need to take the function and place it in our header. So copy this code below:

<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>

Now we are going to go into the appearance editor in WordPress.

wp appearance editor

Now click into your header.php file to edit it. (please back this file up first if you don’t know what you are doing) We are then going to place the custom function right after the opening <body> tag. Now this will vary based upon different WordPress themes. In my example it is being placed into the WordPress Avada Theme. You can see the custom function placed below in my example.

edit header php

Then press the “Save” button at the bottom.

Step 4

Now go back to DuracellTomi’s Google Tag Manager for WordPress plugin settings and click into the “Basic Data” tab. Under the “Posts” section we are going to check the box next to “Post title” and click “Save Changes.”

save post data

Step 5

Now click into the “Search” section and we are going to check the box next to “Search data” and click “Save Changes.”

search data

You have now setup your Google Tag Manager container within WordPress. However it is not running yet until you publish your container. Please keep following the tutorials below to publish.

Genesis Framework

If you are running the popular Genesis framework simply go into “Theme Settings” and input the code into the “Header and Footer Scripts.”

genesis theme settings

How to Implement Google Universal Analytics

We are now going to setup Google Universal Analytics within Google Tag Manager. Make sure to remove your already existing tracking script so you don’t have two running.

Step 1

Login to Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

 

new tag

Step 2

Name your tag Universal Analytics and under the tag type select “Analytics > Universal Analytics.”

google tag manager universal analytics

Step 3

Next you are going to insert your Tracking ID from Google Analytics. Click the box next to “Enable Display Advertising Features” and make sure the track type is selected on “Page View.”

tag manager tracking id

Your tracking ID is simply your UA tag from Google Analytics. To find this simply login to Google Analytics and it should be listed next to your profile.

google UA tag

Step 4

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 5

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the tag and or Universal Analytics script is firing on all pages.

tag manager all pages

Then click “Save” and you have now created your first tag in Google Tag Manager.

Step 6

We now need to publish your container. In the top right click on “Publish.”

google tag manager publish

Step 7

You will see a popup asking you to create a new version. This is one thing I love about Google Tag Manager, it creates versions when you edit things and you can see the entire history of what is added and changed. You can even publish previous versions of your container. Click on “Create Version and Publish.”

google tag manager version publish

Now what I usually do is simply verify that it is working by checking the “Real Time” feature in Google Analytics and see if it is registering me as a visitor. Make sure to clear your cache first if you are testing this way. You can also use the “Preview” function in Google Tag Manager to test before you publish.

How to Implement Google AdWords Conversion Tracking

We are now going to setup Google AdWords Conversion Tracking within Google Tag Manager. There are two ways to track AdWords conversions. One is from importing your Google Analytics goals and other is setting up the conversion pixel to fire. If you are using GA goals then you can skip adding conversion tracking here. If you have them setup manually proceed below. Make sure to remove your already existing tracking script so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag AdWords Conversions and under the Tag Type select “AdWords Conversion Tracking.” Then input your Conversion ID and Conversion Label into the fields below. If you are tracking revenue, which I advise you do, also enter in the Conversion Value.

adwords conversion tracking tag

To find the values above click into your Google AdWords account and click into Tools and select “Conversions.”

tools conversions

Click into your conversion, select the “Code” tab and then “I make changes to the code.” You will then see the conversion_id and conversion_label.

conversion code

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

Now since we are tracking AdWords goals manually I am going to create a new rule because I want it to only fire when users hit my “Thank You” page. Your rules might vary a bit. For me, every web submission form redirects users to the “Thank You” page. So select “Create new rule” and name your rule Thank You Page. Then in the URL field I am putting where it contains /thank-you/. Then click “Save.”

thank you firing rule

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 2). Click on “Create Version and Publish.”

google tag manager version publish

You have now added AdWords Conversion tracking in Google Tag Manager. Read more about setting up Conversion Tracking in AdWords.

How to Implement Google AdWords Remarketing Tracking

We are now going to setup Google AdWords Remarketing Tracking within Google Tag Manager. Make sure to remove your already existing tracking pixel so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag AdWords Remarketing and under the Tag Type select “AdWords Remarketing.” Then input your Conversion ID into the field below.

adwords remarketing tag manager

To find your conversion ID, login to your AdWords account and click into campaigns. Then on the left hand side click into Shared Library and click on “Audiences.”

shared library audiences

On the top right hand side click into “View tag details.”

adwords remarketing tag view details

Click into the Setup tab and then in the box you will see your conversion_id. Copy that to put into Google Tag Manager.

tag setup conversion id

The conversion label you can leave blank.

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the tag and or AdWords Conversion pixel is firing on all pages.

tag manager all pages

Then click “Save.”

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 3). Click on “Create Version and Publish.”

google tag manager version publish

You have now added AdWords Remarketing tracking in Google Tag Manager. Read more about setting up your first AdWords Remarketing Campaign.

How to Implement Bing Conversion Tracking (UET)

We are now going to setup Bing Conversion Tracking within Google Tag Manager. Make sure to remove your already existing tracking script so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag Bing Conversions, and from the drop down select “Custom HTML Tag.” Then input into the HTML box your tracking code from Bing.

bing tag manager

To find your tracking code login to BingAds and click into campaigns. Then click into “Shared Library” on the left hand side and click on “View Goals.” This is assuming you have already setup your goal.

bing shared library

Select your goal and click on “View tag.”

bing view tag

Then copy the Javascript code.

copy bing code

There is no need to setup a firing rule specific to your thank you page because that is setup within the Bing goal itself. And the Bing universal tracking code is meant to be placed on all of your pages.

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the tag and or Bing Conversion script is firing on all pages.

tag manager all pages

Then click “Save.”

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 4). Click on “Create Version and Publish.”

google tag manager version publish

You have now added Bing Conversion Tracking in Google Tag Manager.

How to Implement Facebook Conversion Tracking

We are now going to setup Facebook Conversion Tracking within Google Tag Manager. Make sure to remove your already existing tracking pixel so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag Facebook Conversions, and from the drop down select “Custom HTML Tag.” Then input into the HTML box your tracking pixel from Facebook.

facebook tag

To find the tracking pixel login to Facebook Ads Manager and click on “Conversion Tracking” on the left hand side.

facebook conversion tracking

Then click “View Code” next to your pixel.

view fb pixel

Then copy your pixel code.

copy fb code

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

Now we need to create a new rule because we want it to only fire when users hit our “Thank You” page. Your rules might vary a bit. For me, every web submission form redirects users to the “Thank You” page. So select “Create new rule” and name your rule Thank You Page. Then in the URL field I am putting where it contains /thank-you/. Then click “Save.”

thank you firing rule

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 5). Click on “Create Version and Publish.”

google tag manager version publish

You have now added Facebook Conversion Tracking in Google Tag Manager. Read more about how to setup Facebook conversion tracking.

How to Implement Facebook Remarketing

We are now going to setup Facebook Remarketing Tracking within Google Tag Manager. Make sure to remove your already existing tracking pixel so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag Facebook Remarketing, and from the drop down select “Custom HTML Tag.” Then input into the HTML box your tracking pixel from Facebook.

facebook remarketing pixel

To find the remarketing tracking pixel login to Facebook Ads Manager and click on “Power Editor” on the left hand side.

facebook power editor

Click the drop down box in the top left and click into “Audiences.”

facebook audiences

Highlight your audience and click on the small gear icon and select “View Pixel Code.”

view pixel code

Then copy the pixel code to put into Google Tag Manager.

view custom audience pixel

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the Facebook tracking pixel is firing on all pages.

tag manager all pages

Then click “Save.”

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 6). Click on “Create Version and Publish.”

google tag manager version publish

You have now added Facebook Remarketing Tracking in Google Tag Manager. Read more about how to setup Custom Audiences in Facebook.

How to Implement Perfect Audience Tracking

We are now going to setup Perfect Audience Remarketing Tracking within Google Tag Manager. Make sure to remove your already existing tracking pixel and or Perfect Audience WordPress plugin so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag Perfect Audience Remarketing, and from the drop down select “Custom HTML Tag.” Then input into the HTML box your tracking pixel from Perfect Audience.

perfect audience tag

To find the tracking pixel login to Perfect Audience, click on “Manage” and click on the “Site Tracking Tag.”

perfect audience tracking tag

Then click on “Copy tag to clipboard” and put that into the custom HTML box in Google Tag Manager.

copy perfect audience code

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the Perfect Audience tag is firing on all pages.

tag manager all pages

Then click “Save.”

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 7). Click on “Create Version and Publish.”

google tag manager version publish

You have now added Perfect Audience Remarketing Tracking in Google Tag Manager.

How to Implement CallRail Conversion Tracking

We are now going to setup CallRail Conversion Tracking within Google Tag Manager. Make sure to remove your already existing tracking script and or CallRail WordPress plugin so you don’t have two running.

Step 1

In Google Tag Manager, click into your account, and click into your container. We are now going to create a new tag. So click on the “New” button at the top and select “Tag.”

new tag

Step 2

Name your tag CallRail Conversion Tracking, and from the drop down select “Custom HTML Tag.” Then input into the HTML box your tracking script from CallRail.

callrail tag manager

Find find your CallRail script login to CallRail and click into one of your companies. At the top right click into Integration and then click on “Dynamic Number Insertion.”

callrail integration

Then click on “Copy to Clipboard” to copy the code and insert that into the Custom HTML box in Google Tag Manager.

copy code callrail

Step 3

Next in the top right click on “+Add” next to firing rules.

tag manager firing rule

Step 4

By default there will be an “All pages” rule already created. Go ahead and select that and click “Save.” This will ensure that the CallRail script is firing on all pages so that your dynamic number insertion is working.

tag manager all pages

Then click “Save.”

Step 5

We now need to re-publish your container. In the top right click on “Publish.”

google tag manager publish

Step 6

You will see a popup asking you to create a new version (version 8). Click on “Create Version and Publish.”

google tag manager version publish

You have now added CallRail Conversion Tracking in Google Tag Manager.

I will be adding more to this tutorial as time goes on. As always feel free to leave your comments below, and any shares are greatly appreciated.

Get More Stuff Like This

Marketing, WordPress, Blogging Tips, SEO and Reviews, once a week.

Thank you for subscribing.

Something went wrong.

14 thoughts on “The Complete Google Tag Manager Tutorial (8 Scripts in 1)”

  1. Pingback: The Complete Google Tag Manager Tutorial (8 Scr...
  2. Hi Brian,
    Thanks for the tutorial. Are you considering doing one for Version 2 as well? I’ve been searching for one and can’t find anything.

    Thanks!

    Natalie

    • Hi Natalie,

      I do have plans to release an updated article with the new UI (version 2) in it, as things have definitely changed a little bit. Stay tuned!

  3. This is an incredible resource! I’ve just started implementing GTM today and will definitely be making the move over. What I need to look at is the naming of versions, in case I screw up somewhere.

    • Thanks Thando :) Glad this was helpful for you. I have all my sites and my clients on Google Tag Manager now and it is awesome! Never going back. It’s a great way to stay super organized.

      GTM released their new UI a month ago and so I have plans to update the tutorial above with version 2 and the new UI.

      Good luck on your migration over. Make sure to remember to remove old tracking tags after you publish your container, clear your cache, and verify GTM is working (I usually check out the real-time stats).

      Don’t forget to share :)

  4. Awesome article Brian, great read!

    Do you think it’s possible to use Tag Manager for adding a custom tracking pixel? In this example the Mautic tracking pixel.
    Normally you would do this with:

    A better tracking pixel would add some more parameters. Within PHP you would do that like this:

    $d = urlencode(base64_encode(serialize(array(
    ‘url’ => $_SERVER[‘REQUEST_URI’],
    ‘title’ => $pageTitle, // Use your website’s means of retrieving the title or manually insert it
    ’email’ => $loggedInUsersEmail // Use your website’s means of user management to retrieve the email
    ))));

    echo ”;

    Do you think there a way to achieve this using Tag Manager?

  5. Great article as always Brian! I’d love to see the Perfect Audience section expanded to include the orderId and revenue values passed from WooCommerce. There’s not much documentation for this setup online. Lots of docs explaining how to setup the basic config, but none of them show how to set the GTM Variable and pass that data from WooCommerce.

Leave a Comment

shares