How to Install Google Tag Manager in WordPress in 3 Easy Methods + Plugin Recommendations

How to Install Google Tag Manager in WordPress in 3 Easy Methods + Plugin Recommendations

Google Tag Manager is a free tracking tool that allows you to manage and deploy tags without editing your website’s code.

It is the most popular tag management system, used by over 40% of websites. Not only does it offer easier tag management with little code usage, but also faster page load time and simpler workflow. Furthermore, its preview mode lets you check whether your tags and triggers work before publishing.

Google Tag Manager also has built-in tag templates integrated with Google Ads, Google Analytics, and other third-party tools. As a result, you can easily manage your tags through one dashboard to improve your digital marketing strategies.

This article will walk you through installing Google Tag Manager in WordPress both manually and with a plugin.

We’ll also list five Google Tag Manager plugins and alternatives you can choose to enable advanced tracking on your WordPress website.

How to Install and Set Up Google Tag Manager in WordPress Manually

There are two methods to install Google Tag Manager in WordPress – manually and with a plugin.

While using a plugin might be easier, the manual method gives you more customization options over the code. For this reason, we recommend opting for the manual method for advanced users.

1. Create a Google Tag Manager Account

First, you need to set up a Google Tag Manager account. Follow these steps:

  1. Open the Google Tag Manager homepage. Click Start for Free and log in with your Google account.
  2. Click Create Account, either on the top right or the icon on the page center.
  3. On Account Setup, you will need to fill in your account name. We recommend using your company’s name if it’s for your business.
Fill in your name and country details on the Account Setup
  1. Fill in your domain name and choose Web as your target platform on Container Setup.
  2. Once you’ve filled in all of the information, click Create.
You can target several platforms for tracking with Google Tag Manager
  1. Then, the terms of service agreement window will show. Read the information carefully, and tick “I also accept the Data Processing Terms as required by GDPR.”
Click "Learn more" to know more about GDPR
  1. Click Yes to create your account.
  2. Finally, you will see a pop-up window with two Google Tag Manager code snippets for your website. The first one is for the header, and the second code snippet is for the body section of your website. To copy these code snippets, simply click on the copy icon.
Copy and paste code snippets onto your WordPress website to enable Google Tag Manager

2. Add the Tracking Code to WordPress

The next step is adding the code to your WordPress site. To do so, follow the steps below:

  1. Log in to your WordPress account and navigate to Appearance -> Theme File Editor on your sidebar.
You will find the configuration for theme files in Appearance > Theme File Editor
  1. On the right side, check the Theme Files.
Locate header.php under theme files to customize your head tag

As WordPress themes vary in terms of design and functionality, they may have different types of files. Some typical files include functions.php, footer.php, and header.php., but they may have different names.

The file for the heading, usually named header.php, is where you will make changes with the Google Tag Manager’s code snippets. If you can’t find header.php in your WordPress theme files, contact the theme developer for more information.

  1. After copying the Google Tag Manager code snippet, click header.php and locate the <head> and </head> tags to change the header section. Usually, you can also customize the opening <body> tag in the same file. However, other themes may have the body section in another template file.
  1. Paste the first code for the header section as high in the <head> of the page as possible.
  1. Also, paste the second code after the opening <body> tag.
  1. Click Update File at the bottom of the page to save changes.
  2. Once you’re finished with adding snippets to your WordPress website, go back to your Google Tag Manager dashboard and click Preview.
Use the preview mode to test your tags
  1. It will direct you to a new window to connect Tag Assistant to your website. Enter your site URL and click Connect.
The Tag Assistant window will pop up to start the preview
  1. A new window to your site will open, and Tag Assistant will notify you of the successful Google Tag Manager connection. Click Finish, navigate to the preview window, and click Continue.
Click Continue to finish the preview
  1. You will see the “Google container found” notification along with your Google Tag Manager container ID, meaning the installation of Google Tag Manager on your WordPress website is complete.
The "Google container found" notification indicates the installation is finished
  1. Close the preview window, and click Submit.
Submit your changes on Google Tag Manager
  1. After that, enter the version name. For example, you can name it “GTM on WordPress”. Then, click Publish.
Add a name and description (optional) before publishing

3. Publish a New Tag

You will need to create a tag to start using Google Tag Manager for tracking user behavior. To accomplish this, follow the steps below:

  1. Navigate to your Google Tag Manager dashboard and click Add a new tag, where you can choose from more than 50 tags supported by Google Tag Manager.
Find the New Tag configuration on your dashboard
  1. Click on the icon to choose a tag type.
Click the icon to choose a tag
  1. Then, you will see many featured tag types on the list, including several Google Analytics tags. You can choose the Universal Analytics tag if you have a Google Universal Analytics account.
Choose Google Analytics tag to use Google Tag Manager for tracking
  1. For Track Type, select which element you want to track on your WordPress website from the list. Also, choose New Variable for the Google Analytics settings.
In Tag Configuration, you can configure the track type, Google Analytics settings, and advanced settings
  1. Then, a variable configuration window will show. Enter your Google Universal Analytics tracking ID, rename the variable, and click Save. You can find your tracking ID in the Admin tab under Property -> Tracking Info.
Rename your variable with a suitable name
  1. After that, move on to the next section to choose a trigger.
Click the icon to choose a trigger
  1. Tick the triggers you want to use, and click Add.
You can choose the triggers you want to use from the list
  1. Then, rename the tag and click Save. Before publishing your tag, use the Preview mode to check if the tag works on your website.

That is it – you have successfully created a Google Analytics tag.

Pro Tip

Google has announced that Google Universal Analytics will no longer operate by July 2023, and Google Analytics 4 will replace it. Therefore, we recommend you start using Google Analytics 4 sooner to export your files before losing access to Google Universal Analytics. This tutorial will also refer to Google Analytics 4 tag type as an example.

If you already use a Google Analytics 4 account, choose Google Analytics: GA4 Configuration tag on Google Tag Manager, and click Save.

You can find tag types for Google Analytics 4 on Google Tag Manager

Unlike Universal Analytics, you will have to enter your measurement ID in tag configuration. To get it, set up a data stream on your Analytics’ Property tab first.

Enter your Google Analytics 4 measurement ID in the Tag Configuration

Click Save, and you can continue with the steps we’ve explained to set up a trigger for the Universal Analytics tag.

Now that you’ve set up a Google Analytics tag, the steps to manually installing Google Tag Manager on your WordPress site are complete.

How to Add Google Tag Manager in WordPress With a Plugin

The second method to install Google Tag Manager for WordPress is by using a plugin, which is a more suitable option for beginners.

You should start by following the steps to create a Google Tag Manager account explained in the previous part.

Adding the Tracking Code to WordPress

After installing a WordPress plugin, adding the tag manager code will be easier as you don’t need to locate template files and manually add the code snippets to the <head> and <body> tags.

We will show you how to install Google Tag Manager on your WordPress website using the Insert Headers and Footers plugin as an example.

  1. Once you’ve created a Google Tag Manager account, navigate to your WordPress admin page. Go to Plugins -> Add new, search for the Insert Headers and Footers plugin, then click the Install Now button.
Install and activate Insert Headers and Footers plugin on your WordPress site
  1. After that, navigate to Settings -> Insert Headers and Footers. You will see its configuration settings where you can add code from Google Tag Manager.
  2. Copy the code snippets from your Google Tag Manager account and paste them onto the boxes.
With a plugin, you can copy your snippet codes without having to edit template files
  1. Click Save once you’ve finished.

Next, follow the steps to create a Google Analytics tag explained earlier, and don’t forget to check via the preview mode before publishing the tag.

5 Best Google Tag Manager Plugins and Alternatives

You can also use a plugin for a simpler Google Tag Manager setup and extra functionality. However, with so many Google Tag Manager plugin options available, it can be difficult to choose the best plugin for your WordPress site.

To help you decide, we’ve listed the five best Google Tag Manager plugins and alternatives based on their features, rating, and pricing.

1. MonsterInsights

MonsterInsights' advanced analytics dashboard

Plugin stats:

  • Downloads: 3+ million
  • Rating: 4.5/5
  • Best for: business websites, eCommerce stores, publishers, developers, and agencies
  • Price: freemium ($99.50-$399.50/year)

MonsterInsights is a Google Analytics plugin that allows you to track your website analytics from your WordPress dashboard. With this WordPress plugin, you can set up advanced tracking across devices and campaigns without having to code.

Therefore, it is arguably the best Google Tag Manager alternative, especially when running a business website. MonsterInsights is an all-in-one tool where you can enable tracking, data analytics, and custom reporting.

To use this plugin, simply install and activate it and follow the steps in its quick setup wizard. Just fill in your business and supporting information, then connect WordPress to Google Analytics. With MonsterInsights, you don’t need to visit your Google Analytics dashboard to make changes.

This plugin also integrates with other tools or software. For example, it lets online store owners connect their WooCommerce sites with Google Analytics to gather more comprehensive sales data.

Key Features

  • Link and button click tracking. Track link and button clicks without setting up tracking and coding to optimize your digital marketing strategies.
  • Form conversion tracking. You don’t have to create tags to track your form performance as in Google Tag Manager. Simply install its form addon, and the plugin will be able to track your performance.
  • Track eCommerce performance in a few clicks. To enable this feature, you will also need to install its addon. It will be easier to track conversion source, revenue, product performance, and other metrics in Google Analytics with the plugin.

Cons

  • The free version has limited resources.
  • The premium version costs more than other plugins on the list.

[DOWNLOAD]

2. Site Kit by Google

Site Kit, Google's official WordPress plugin

Plugin Stats:

  • Downloads: 2+ million
  • Rating: 4/5
  • Best for: website owners, developers, agencies, plugins providers, and hosting companies
  • Price: free

Created by Google, Site Kit is a WordPress plugin that provides insights into your site visitors’ behavior. With this plugin, you can connect to several Google products and gain beneficial and up-to-date insights to improve your site.

This plugin suits beginner users as its interface is clean and easy to use. Moreover, this plugin is completely free and official.

Site Kit offers an easy 3-step setup, and you just need to sign in to your Google account. You can also connect Google Analytics as part of the setup.

To access the tag configuration through your WordPress admin page, navigate to Site Kit -> Settings -> Connect More Services -> Set up Tag Manager.

You can connect several Google services through Site Kit's dashboard

Select your Tag Manager account and container, and click Confirm & Continue to finish the setup.

Key Features

  • The best Google tools on WordPress. By connecting to your Google account, you can access Google services such as Analytics, Search Console, AdSense, and Tag Manager, all in one place without editing your website code.
  • Stats for the whole site and every page. Get easy-to-understand recommendations from Google on your WordPress dashboard to optimize your content and site. Also, you can use the Optimize feature for A/B testing.
  • PageSpeed Insights. Compare your site performance with other websites to improve it further with actionable tips.

Cons

  • It may not be as detailed as other plugins offering specific functionality.
  • Little control over the configuration as you can only enable or disable connected Google services.

[PREVIEW / DOWNLOAD]

3. Google Tag Manager for WordPress (GTM4WP)

Google Tag Manager for WordPress (GTM4WP) plugin

Plugin Stats:

  • Downloads: 600,000+
  • Rating: 4.5/5
  • Best for: eCommerce stores, musician websites, developers
  • Price: free

Google Tag Manager for WordPress (GTM4WP) is open-source software that helps you place code snippets correctly to modify the <head> and <body> tags on your website. It offers enhanced eCommerce tracking and integrations, for example, with Google Optimize.

Also, you can add information to the data layer to help enable extra features in tags. Events and variables will pass through the data layer, and you can set up triggers based on the values of variables.

Once you’ve installed and activated this plugin, go to Settings -> Google Tag Manager -> General. You will see the configuration for container code placement under the General tab. Enter your Google Tag Manager container ID and click Save changes.

Enter your Google Tag Manager ID on GTM4WP's configuration menu

Key Features

  • Media player events. Track visitors’ interactions with embedded media on your website, including YouTube, Vimeo, and Soundcloud. You can go to GTM4WP’s Settings -> Events -> Media events to enable this tracking. This feature might be beneficial for musician websites.
  • Scroll tracking. Fire tags based on how users scroll through your site.
  • Blocklist and safelist tags, triggers, and variables. Prevent certain tags from firing by blocklisting and safelisting them on the configuration menu. Doing so will add an extra layer of security.

Cons

  • The media events tracking is an experimental feature that can affect your site load speed.

[DOWNLOAD]

Header Footer Code Manager by 99robots

Plugin Stats:

  • Downloads: 300,000+
  • Rating: 5/5
  • Best for: bloggers, business websites, developers, and agencies
  • Price: freemium ($35-$139/year)

Header Footer Code Manager (HFCM) is a straightforward and lightweight WordPress plugin for adding snippets to your website’s header, footer, and content without editing your WordPress theme. Aside from tracking code, you can also add conversion pixels and other scripts for customizing a new feature for your website.

As HFCM supports all scripts, you can manage many snippets with one plugin. In terms of user-friendliness, it offers a clean UI, and you can easily control your snippets with the on/off toggle. Additionally, you can choose to load scripts based on device type – mobile, desktop, or both.

To begin using this plugin, navigate to HFCM -> Add New on your sidebar. With HFCM, you will need to create two separate snippets for the head section and footer.

Enter your snippet name and paste your Google Tag Manager snippet. For example, name it “Google Tag Manager Header.” Choose Header as the location, paste the code snippets, and click Save.

Create a snippet for the heading section

Create another snippet for the Footer. In this example, we’ll name it “Google Tag Manager Footer.” Make sure the location is the footer, paste the code for the opening <body> tag, and click Save.

Create another snippet for the body part

Key Features

  • Snippet targetting. Target elements for scripts or exclude scripts from appearing on particular pages, posts, taxonomies, or archives to avoid having unnecessary code.
  • Manage a large number of scripts. Additionally, label each snippet to help you remember their purpose easily.
  • HFCM shortcodes. Add snippets manually in the form of shortcodes at a specific part of your WordPress theme. You will be able to monitor, edit, and manage your code snippet and other snippets without having to edit the theme file each time.
  • Variety of script types. Some of the supported snippets and pixels include Marketing/CRM snippets, Facebook pixel, and Google Analytics which can support your digital marketing efforts.

Cons

  • Some advanced features, such as the unlimited number of scripts, shortcodes, and body tag snippets, are only available in the premium version.

[DOWNLOAD]

Tag Manager by YYDevelopment

Plugin Stats:

  • Downloads: 10,000+
  • Rating: 5/5
  • Best for: bloggers, small business owners
  • Price: free

Tag Manager by YYDevelopment is a free WordPress plugin for inserting code into your site from Google Tag Manager, Google Analytics, or Facebook Pixel. With this plugin, you can add code below and above the closing <body> tag. Additionally, you can add meta tags or make changes to your head section with a custom HTML footer code injection.

The plugin is very easy to use, and the setup takes only a few clicks. Once you’ve downloaded and activated this plugin, navigate to Tag Manager on your sidebar and paste the code from your Google Tag Manager account.

Paste Google Tag Manager snippet codes onto the boxes

Key Features

  • Injection location and feature. With the Tag Manager plugin, you can add snippets to your WordPress site’s head, body, and footer sections. Also, adding more than one code in each part is possible.
  • Exclude code from users. For security reasons, you will be able to exclude code from users you share access with.
  • Google and other platforms are supported. It is compatible with Google’s key products, social media platforms, and any other website that requires code injection.

Cons

  • Limited functionality. Tag Manager might not suit larger businesses that require advanced features.

[DOWNLOAD]

Conclusion

Google Tag Manager is a tracking tool for managing and deploying tags on your website with little code usage and easy workflow. With many tag types supported by this tool, you can integrate it across platforms to get insights into user behavior and improve your digital marketing strategies.

There are two methods to install Google Tag Manager on your WordPress website: manually and with a plugin. While the manual method is more suitable for users with advanced technical knowledge, we recommend using a WordPress plugin for beginners.

Additionally, here are our five best Google Tag Manager plugins and alternatives for WordPress websites:

  • MonsterInsights, Header Footer Code Manager best for large business websites, eCommerce stores, developers, and marketing agencies.
  • GTM4WP – best for users who want to track interactions with embedded media.
  • Tag Manager – best for small business owners and personal blogs.
  • Google Site Kit best for users who want a simple UI with excellent performance.

We hope this article helps you understand how to install Google Tag Manager on your WordPress website. Should you have any more questions, leave a comment below. Also, we recommend checking our WordPress guide in case you have general questions about this CMS.

Author
The author

Nadia Maya Ardiani

Maya is a Content Writer and WordPress Contributor. With years of journalistic experience under her belt, her main goals are to help people understand complex processes in a simpler way, and tell the stories of people who thrive thanks to technology. When she’s not writing, you can find her watching sci-fi movies while eating ramen. Follow her on LinkedIn.

Author
The Co-author

Nadia Daniel

Nadia is a curious thinker that enjoys sharing her IT and digital marketing knowledge through written pieces and helping people success online. In her free time, she spends time in the streets or cafes learning about architecture and culture through urban sketching.