Setting up Google Tag Manager with Google Analytics

Google Tag Manager is an easy way to manage all the tracking codes between your website and other tools that use their own tracking codes, like Google Analytics, LinkedIn Insight, Pinterest tag, Quora Pixel, Shareaholic, Twitter Universal Website Tag, etc.

The best part is that you only need to add one piece of code to your website, and then you never have to worry about trying to add tracking codes again. A developer usually does this part or requires a few advanced skills. Don’t worry, this post will show you how to do this by yourself so that you can feel like a website geek for the day!

Let’s create your Google Analytics 4 account

If you already have a Google Analytics account, but it is still using the older Universal Google Analytics, you can follow the steps in the video below to change over to Google Analytics 4:

Create your Google Tag Manager account and connect your Google Analytics 4

Go to https://tagmanager.google.com/ and sign in with the Gmail account that you use for all your business needs. This is important to take note of as you might have various Gmail accounts, and this can get very confusing. Always use the same Gmail account that you will use for your Google Analytics, Search Console, Google Optimize, and Google Tag manager. This makes the entire ecosystem much easier to integrate with each other.

To create an account, you can follow the steps over here or watch the video down below:

Next, we need to do the Geek part and install the Google Tag Manager code on your website.

The first thing we need to do is to add the plugin Code Snippets to your website. I find this plugin the easiest to use for many other applications that you might need it for in the future as well.

You can watch the video below or follow the steps underneath to add the Google Tag Manager code to your website.

First, we must copy the code below into the Code Snippets plugin. So go ahead and click anywhere on the code box below to copy the code to your clipboard.

add_action( 'wp_head', function () { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-YOURCODE');</script>
<!-- End Google Tag Manager -->
<?php }, 1 );
add_action( 'wp_footer', function () { ?>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-YOURCODE" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<?php }, 1 );
  1. Open the Code Snippets plugin and click on Add New:

2. Enter a title for this piece of code, like GTM-Code.

3. Paste the code that you have copied above on the first line as indicated in the picture below:

4. Replace the Container ID indicated (in red in the code above) with the container ID you have created in Google Tag Manager:

5. Make sure that the ‘Run snippet everywhere’ is selected as indicated by the arrow in the above image.

6. Click on the ‘Save changes and Activate’ button.

Let’s test it to see if the Google Tag Manager code is installed correctly.

Firstly, install a Google Chrome extension: Tag Assistant Legacy (by Google)

This is very important to help you figure out if your tags are working and activate the debugging mode in Google Analytics.

  1. Go to your Google Tag Manager and click on the preview button:

2. Add your website URL in the pop-up box that will appear in a new window. Make sure that your browser is not blocking the pop-up.

3. Click on Connect. Your website will open up on a new page, and if everything is connected properly, you should see the following at the bottom of your screen:

On the Tag Assistant page, you should see this message too:

4. Time for a happy dance as you just Geeked out!

Ready to start tracking

Now that your Google Analytics is set up and working, it is time to learn how to use Google Analytics to track your customer journey and gain valuable insights for marketing purposes.

We will cover this in more detail in the Introduction to Google Analytics masterclass, which you are welcome to attend in your own time over here.

Leave a Reply