How to Install Google Tag Manager on WordPress [VIDEO]


Written by

Dave Warfel

Reading Time

4 minutes

If you buy something from one of our links, we may earn a commission.

Google Tag Manager (GTM) is a small piece of code that you can add to your WordPress site that allows you to add various other tracking scripts, remarketing tags, etc. to your site, all through an easy-to-use interface. Setup Google Tag Manager one time, and then add unlimited scripts to your website without ever touching another line of code. Pretty awesome, right? Especially for marketers and less technical site owners, GTM can provide immense value.

I’ll walk you through the process of installing Google Tag Manager on WordPress. Step-by-step instructions below the video.

1. Create a Google Tag Manager Account

The first thing we need to do is setup an account with Google Tag Manger.

1a. Setup Account

There are two levels of access with GTM: accounts & containers. An account should be thought of as your larger organization. A container is a specific website, or URL. One organization (account) might own and operate three different websites (containers). This follows Google’s recommendation.

  • Give your account a name

1b. Setup Container

Your container is the actual website that you want to add scripts to.

  1. Give your container a name. You should use your site’s domain name. Either or
  2. Where to use container – Choose “Web”
    • If you were creating a mobile app, you would choose iOS or Android, for the appropriate operating system you were developing on
  3. Click “Create”  (and agree to the Terms of Service)

2. Install Google Tag Manager on WordPress

You should immediately be prompted with a modal window that contains your unique Google Tag Manager code. However, if you aren’t…

  1. In the top navigation, click “Admin”
  2. In the second column, under “Container,” make sure your container is displayed
  3. Further down that column, click “Install Google Tag Manager”
    • This will take you to a screen with your unique code
  4. Copy this code
Google Tag Manager WordPress - Find Install Code
Where to find your unique GTM install code

2a. Add Code to Your Theme

It is possible to add Tag Manager via a plugin, or an action hook that fires right after the opening <body> tag. However, one of the quickest & easiest ways to install GTM is placing the code in your theme’s header.php file.

If your theme does not have a header.php file, reach out to the theme developer and let them know what you’re trying to do. Ask them which file you need to update in order to insert code on every page, right after the <body> tag.

NOTE: If you switch themes, be sure to transfer this code to your new theme.

  1. Open up your favorite code editor. We use Sublime Text, but TextEdit (Mac) or Notepad (PC) will do the trick.
  2. Open your header.php file
  3. Search for <body
  4. Add your unique Google Tag Manager script on the next line, after the <body> tag
    • The code below has a fake GTM ID (GTM-ABC123). Be sure you copy the unique code from your admin area.
<body <?php body_class(); ?>>
<!-- Google Tag Manager -->
<noscript><iframe src="//"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->
  1. Then just upload this file to your server using an FTP program (FileZilla)

NOTE: If you’re using a theme that is updated frequently, you should definitely consider creating a child theme, and adding this to the header.php file of your child theme.

Two simple steps. Now that you have Google Tag Manager installed on your WordPress site, you’re ready to start adding tags. How about adding Google Analytics with Tag Manager as your first tag?

Dave Warfel

LinkedIn  •  X (Twitter)Dave has been working with WordPress since 2011. He's built 100s of client sites and almost a dozen of his own. He's tested almost every plugin you can think of, hosted with at least 10 different companies, and gone down every SEO rabbit hole you can imagine. When's he's not tinkering with new software, you'll find him in the mountains of Colorado, trail running, summiting peaks, and rippin' downhills on his mountain bike. 🏔️🏃🚴🤸

Leave a Comment