How to Add Google Tag Manager to WordPress Site

Are you a beginner looking for a way to add Google Tag Manager to a WordPress site?

Google Tag Manager is a free tracking tool that lets you control and deploy tags without changing the code of your website.

It is the popular tag management system, with over 40% of websites using it. It not only provides better tag management with less code usage, but it also provides faster page load time and a simpler workflow. Additionally, its preview mode allows you to test whether your tags and triggers work before publishing.

Further, Google Tag Manager provides built-in tag templates that are connected to Google Ads, Google Analytics, and other third-party tools. As a result, you can quickly manage all of your tags from a single dashboard, allowing you to better your digital marketing strategies.

In this article, we’ll show you two methods to add Google Tag Manager to your WordPress website.

How to Add GTM to WordPress Manually

Google Tag Manager can be installed in WordPress manually or through a plugin.

While using a plugin may be easier, the manual method gives you greater control over the code. As a result, for advanced users, we recommend the manual method.

Create a Google Tag Manager Account

To start, go to the Google Tag Manager website and click the Start for free button.

Sign Up for Google Tag Manager

After that, you should sign in using your Google account. When you’re finished, you’ll be taken to the Google Tag Manager Create Account page. Just click on the Create Account button to get started.

Create Google Tag Manager Account

Next, you can add a new account. In the Account Setup box, enter your account name and select a country. You can use your website name as your account name.

Account Setup in GTM

The next step is to set up your container. A container is a grouping of tags, triggers, and all configurations installed on a website.

You can use your website’s name as the container name. After that, choose Web as your target platform and click the Create button.

GTM Container Setup

To proceed, you need to agree to the Google Tag Manager Terms of Service Agreement. Check the checkbox next to I accept the Data Processing Terms as required by GDPR at the bottom, and then click the Yes button in the top right corner.

Accept Google Tag Manager Terms of Service

After accepting the terms of service, a new popup window will display on the screen containing code snippets for installing Google Tag Manager on your website.

Google Tag Manager Installation Codes

There are two code snippets to be placed in the header (inside head tag) and in the body section on your website.

Adding Google Tag Manager Code to WordPress Without Plugin

To add GTM code, go to Appearance » Theme File Editor from your WordPress dashboard.

Now, look for the header.php file from the list of files on the right.

WordPress Theme File Editor

However, If you cannot find the header.php file, look for index.php, where you can see the head and body parts of your website.

Now, go to your GTM account and copy the header code, which you should place just after the opening head tag in the header.php file.

Next, copy the body code and paste it right after the opening body tag.

Add Google Tag Manager Code in WordPress Theme File Editor header.php File

Once done, click Update File at the bottom of the page to save changes.

When you’re done adding code snippets to your WordPress website, return to your Google Tag Manager dashboard and click Preview.

GTM Preview Button

It will show you a new window where you can link Tag Assistant to your website. Enter your website’s URL and click Connect.

Connect Tag Assistant to Your Site

A new window to your site will appear, and Tag Assistant will alert you of the successful Google Tag Manager connection. Click Finish, then go to the preview window and click Continue.

Click Continue to Finish the Preview

Now, you will see the “Google container found” notification along with your Google Tag Manager container ID. This shows the complete installation of Google Tag Manager on your WordPress website.

Google Container Found

Close the preview window and click Submit.

Submit Your Changes to Google Tag Manager

Now, a new popup appears, asking you to enter your version name. You can, for example, name it “GTM on WordPress.” Then click Publish.

Add GTM Version Name Before Publishing

Add a New Tag in Google Tag Manager

After you’ve installed Google Tag Manager on WordPress, you’ll be able to add tags provided by various tracking tools to your site.

Google Tag Manager supports more than 50 different tag types, including those used by Google marketing products and other third-party services. Additionally, you can use its interface to include unique HTML or JavaScript tags on your website.

Go to your Google Tag Manager dashboard and click Add a new tag link.

Add New tag in Google Tag Manager

On the next screen, click the icon to choose a tag type.

Click the Icon to Choose the Tag

Next, you will see a list of different tag types, including a number of Google Analytics tags. If you use a Google Universal Analytics account, you can select the Universal Analytics tag.

Choose Google Analytics Tag to Use Google Tag Manager for Tracking

For Track Type, select the element you want to track on your WordPress website from the list. Additionally, choose New Variable for the Google Analytics settings.

Configure Track Type and Google Analytics Settings

Following that, a variable configuration window will appear. Rename the variable, then enter your Google Universal Analytics tracking ID and then click Save. You can find your tracking ID on the Admin tab under Property » Tracking Info.

Rename Variable and Enter Google Analytics Tracking ID

After that, move on to the next step to select a trigger.

Click the Icon to Choose a Trigger

Check the triggers you want to use and click the Add button.

Choose Your Trigger From the List

Once done, click the Save button in the workspace’s top right corner.

That’s all! You can successfully create a Google Analytics tag.

How to Add GTM Code to WordPress Using Plugin

The second method for setup Google Tag Manager on WordPress is to use a plugin, which is a better alternative for beginners.

Adding GTM Code to WordPress

To start, first, you need to install and activate the WP Headers and Footers plugin. If you’ve never installed a plugin before, see our guide on how to install a WordPress plugin.

Upon activation, go to Settings » WP Insert Headers and Footers.

Now, copy the code snippets from your Google Tag Manager account and paste them onto the boxes.

Copy and Paste the Google Tag Manager Code in WP Headers and Footers WordPress Plugin

Once done, click the Save Changes button.

Conclusion

Google Tag Manager is a tracking tool that allows you to manage and deploy tags on your website with minimal code and a simple workflow. With so many tag types supported by this tool, you may connect it across platforms to gain insights into user behavior and better your digital marketing campaigns.

Google Tag Manager can be installed on your WordPress website manually or with a plugin. While the manual method is best suited for people with advanced technical skills, we suggest using a WordPress plugin for beginners.

We hope this guide helps you to learn how to install Google Tag Manager on your WordPress website.

Related Articles