How to Install Google Tag Manager in WordPress: Quick 3-Step Process and 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 Setup 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:
- Open the Google Tag Manager homepage. Click Start for Free and log in with your Google account.
- Click Create Account, either on the top right or the icon on the page center.
- 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 domain name and choose Web as your target platform on Container Setup.
- Once you’ve filled in all of the information, click Create.
- 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 Yes to create your account.
- 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.
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:
- Log in to your WordPress account and navigate to Appearance -> Theme File Editor on your sidebar.
- On the right side, check the Theme Files.
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.
- 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.
- Paste the first code for the header section as high in the <head> of the page as possible.
- Also, paste the second code after the opening <body> tag.
- Click Update File at the bottom of the page to save changes.
- Once you’re finished with adding snippets to your WordPress website, go back to your Google Tag Manager dashboard and click Preview.
- It will direct you to a new window to connect Tag Assistant to your website. Enter your site URL and click Connect.
- 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.
- 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.
- Close the preview window, and click Submit.
- After that, enter the version name. For example, you can name it “GTM on WordPress”. Then, click Publish.
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:
- 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.
- Click on the icon to choose a tag type.
- 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.
- 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.
- 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.
- After that, move on to the next section to choose a trigger.
- Tick the triggers you want to use, and click Add.
- 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.
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.
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.
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
With 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.
- 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.
- After that, navigate to Settings -> Insert Headers and Footers. You will see its configuration settings where you can add code from Google Tag Manager.
- Copy the code snippets from your Google Tag Manager account and paste them onto the boxes.
- 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.
- 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 to your Google Analytics account. With MonsterInsights, you don’t need to visit your Google Analytics dashboard to make changes.
- 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.
- The free version has limited resources.
- The premium version costs more than other plugins on the list.
2. Site Kit by Google
- 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.
Select your Tag Manager account and container, and click Confirm & Continue to finish the setup.
- 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.
- 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.
3. Google Tag Manager for WordPress (GTM4WP)
- 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.
- 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.
- The media events tracking is an experimental feature that can affect your site load speed.
4. Header Footer Code Manager
- 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.
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 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.
- 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.
- Some advanced features, such as the unlimited number of scripts, shortcodes, and body tag snippets, are only available in the premium version.
5. Tag Manager – Header, Body, and Footer
- 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.
- 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.
- Limited functionality. Tag Manager might not suit larger businesses that require advanced features.
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.