WordPress interface showing Google Tag Manager plugin page.

How To Add Google Tag Manager to a WordPress Site

Last Updated & Reviewed: 27th June 2021
Updated By: Chris

Introduction

This article will teach you how to add Google Tag Manager to a WordPress website to track its performance.

Prerequisites For This Process
The prerequisites for this workflow are:

  • A good working knowledge of the WordPress administration area
  • A Google account.
  • A WordPress website for which you manage the web hosting (please click this link, if you need high quality WordPress web hosting)

Quick Overview Of Google Tag Manager

What Is Google Tag Manager?

Google Tag Manager is an important tool for understanding what audiences like on your site, where they are getting lost in the process, and which areas of your content need improvement. With this information at hand, you can pinpoint specific sections that might be causing a slowdown or sticking point within the user flow–alongside other metrics such as time spent per page visit or bounce rate–to see if it’s worth tweaking them any further.

How Long Does It Take To Add Google Tag Manager?

It should take you no longer than 10 minutes to complete, and I assume you have a reasonable knowledge of working with WordPress.

Why Do I Need Google Tag Manager?

Why is this task important – Google Tag Manager is a great tool to add, and manage, multiple pixels and tracking codes without the need to edit the WordPress code itself.

This work-flow is carried out only once – Google Tag Manager is a one time WordPress install.

Get Your Working Environment Setup

For the purpose of this tutorial, we will be using Chrome…

1 – Download the Google Tag Assistant Legacy Chrome Extension (Free)

2 – Sign up for Google Tag Manager (Free):

a) You’ll need to log in to your Google account.

b) If you don’t already have a Google Tag Manager Account, you’ll be prompted to set up.

      • Use your company/website name for both the account and container.
      • Under “Where to Use Container”, select “Web”

How to create a Google Tag Manager account

c) Accept the terms and conditions.

d) You will see your Google Tag Manager code, but you won’t need it using this method.

e) Once, you are in your Workspace, make note of your Google Tag Manager ID
How to find your Google Tag Manager ID

f) Click submit
Google Tag Manager - Submit button

g) Click Publish
How to publish your Google Tag Manager ID

h) Click on Continue to publish your Google Tag Manager container
How to add the Google Tag Manager description

And finally, all done!
Viewing your Google Tag Manager account

How To Install and Set up The Google Tag Manager WordPress Plugin

  1. Log into your WordPress site.
  2. In the WordPress sidebar, go to Plugins > Add New.
  3. Enter “Google Tag Manager for WordPress” in the search box.
  4. Install the Google Tag Manager for WordPress plugin (the image may vary).
    Google Tag Manager WordPress plugin
  5. Activate the plugin.
  6. In the WordPress sidebar, go to Settings > Google Tag Manager.
  7. Paste your Google Tag Manager ID (the one you got from the Google Tag Manager dashboard) in the available field.
    Paste your Google Tag Manager ID into WordPress
  8. The plugin offers several ways to install the container code on your site. Before you implement any of these, we recommend you create a backup of your site.
Option 1: Codeless injection (best option)
  1. With this option, the plugin will try to figure out the right placement for the container for you. This is the easiest option, but there’s a small risk it might break something on the frontend of your site. If you decide to go with codeless injection, select this option from the list and click “Save changes”.
    Codeless injection of your Google Tag Manager ID in WordPress
    After selecting this, visit the website in a new tab or window and make sure everything looks right. If it does, you can move on to the next step of Checking the installation.
Option 2: Custom(for advanced WordPress users)
  1. With this option, you will need to make a small edit to your theme files. If your WordPress theme allows you to make changes, and you’re comfortable with the theme editor, you can use this option. Select the “Custom (needs tweak in your template)” container code placement and click on “Save Changes.”
    Adding your Google Tag Manager ID in your WordPress theme
  2. Copy the PHP code provided by the plugin and click on “Save Changes”.
    Copying the Google Tag Manager code for placement in the WordPress theme
  3. In the WordPress sidebar, go to Appearance > Theme Editor.
  4. Make sure that you are editing the theme that you currently have installed in your site (you can go to Appearance > Themes to check the name of the theme you are using). Adding Google Tag Manager code to your theme files
  5. Select the “Theme Header” template from the list on the right.
    Choosing the right them file to add your Google Tag Manager PHP code
  6. This template is different depending on the theme that you have installed. However, you will always be able to find an opening tag in the code.
    Pasting the Google Tag Manager PHP code into the theme header file
  7. Paste the PHP code provided by the plugin right below the opening tag.
    Pasting the Google Tag Manager PHP code below the body tag in your WordPress header.php file
  8. Click the button in the bottom left, labelled “Update File”.

How To Test If Google Tag Manager Is Working

Using The Google Tag Assistant Chrome Extension

  1. Open your website homepage using Chrome.
  2. Click on the Google Tag Assistant Chrome Extension.
    Open the Google Tag Assistant to test your WordPress Google Tag
  3. Click on “Enable”.
  4. Refresh the page and click on the Google Tag Assistant Chrome Extension again.
  5. You should see a green tag for Google Tag Manager, indicating that the installation was successful.
    Google Tag Manager test result shows the Tag is successfully installed in WordPress
Scroll to Top

Main Menu

Account Menu

© 2026 All rights reserved. Patrick Internet Limited