How to Install Google Tag Manager in WordPress: Quick 3-Step Process and Plugin Recommendations
Google Tag Manager is a tag management tool that helps track traffic, conversions, and other statistics related to site performance.
It consolidates all of your marketing tools’ tags into a single, centralized dashboard. This allows you to easily manage and preview all tracking tags before pushing them to your WordPress website or to roll back to previous versions if something goes wrong.
Applying it to your WordPress website has a bit of a learning curve, but we will explain what Google Tag Manager is, why you should use it, and how to install it on a WordPress site.
We’ll also provide the best GTM plugin recommendations so you can quickly set up Google Tag Manager in WordPress.
What Is Google Tag Manager?
Google Tag Manager is a tag management system that allows you to add and manage tags on a single dashboard. It helps streamline work since you don’t have to add and remove tags from the code one by one.
One example is the Google Ads conversion tracking tag. This tag lets you know if a website visitor who clicked your ad eventually completed a valuable action, such as making a purchase or signing up for a subscription plan.
By using this tool, users can deploy tags on their website without having to edit any code, which is especially helpful for non-technical users. If you’re an advanced user, it is also possible to add your own tracking code with custom HTML.
There are various tags that are natively supported by Google Tag Manager, such as Google Analytics that collects traffic and audience data and Google Consumer Surveys which measures website satisfaction.
It also works with many third-party tags and variable templates, like 2BCookie Consent Manager, which collects and handles consumers’ consent.
There are two ways to install Google Tag Manager on a WordPress website – manually or by using a plugin. The manual way comes with a user-friendly interface, but it is somewhat difficult. To quickly integrate this tool, opt for the plugin instead.
Reasons to Use Google Tag Manager in WordPress
Without a centralized tool, it will be challenging to maintain all the site’s tags. For example, if you need to update the tags, you’ll need to tweak different code snippets, which is not a beginner-friendly task.
Even for experienced users, this is not a practical way to update tags, and there’s a big chance of making an error.
Here are the benefits of using Google Tag Manager on a WordPress site:
- Easy to update – its easy integration allows you to deploy tags quickly. You’ll no longer have to manually add code blocks to web pages.
- Fewer errors – handle critical data more safely with its user-friendly error checking and fast tag loading. This helps ensure that the site runs properly, even when its traffic is getting heavy.
- Comprehensive data collection – obtain various website analytics data on conversions, page views, social shares, and more. This will help plan and optimize your future marketing strategies.
- Multifarious tags – Google Tag Manager supports many built-in and third-party tags to track activity across all sites and apps. It also supports custom HTML to create unlimited tags.
- Free tool – it’s packed with lots of features and is free to use. There’s also a premium version, which comes with additional workspaces and 24/7 support.
- Support team access – its access controls make it possible for your team to collaborate. It also provides multi-environment testing to ensure everything works smoothly.
How to Add Google Tag Manager to WordPress
WordPress.com doesn’t provide its users with full website control, so they have minimal customization options. This condition renders users of the free WordPress.com plan unable to upload any plugins, add Google Analytics, or install tracking platforms on their sites.
WordPress.com’s Business and VIP plans allow their users to install plugins for a monthly or yearly fee, and Business plan users can install Google Analytics. However, both plans still don’t allow any tracking platform to operate on them.
On the other hand, WordPress.org site owners are free to set up Google Tag Manager on their WordPress sites.
1. Sign Up for a Google Tag Manager Account
The first thing you need to do is create a Google Tag Manager account. Here’s how to do so:
- Go to the Google Tag Manager webpage, then click the Start for free button to sign up.
- Sign in with a Google account. If it’s a company account, use the company email instead of your personal address.
- Once done, you’ll see the Accounts section. Click either the Click here to create an account link or the Create Account button.
- You’ll arrive at the Add a New Account form. Under the Account Setup section, enter an Account Name and Country. If it’s a company account, use the company name as the account name.
- Scroll down to see the Container Setup section. A container is the collection of all configurations installed on a website, which include tags and triggers. Use your WordPress website name as the Container name.
- Under the Target platform options, click on Web.
- Hit the Create button.
- A pop-up will appear, prompting you to accept the Google Tag Manager Terms of Service Agreement to continue the process.
Simply tick the box I also accept the Data Processing Terms as required by GDPR and click the Yes button on the window’s top-right corner.
- A new window will appear, showing two code snippets that you’ll need to add Google Tag Manager to the website.
In the next step, this Google Tag Manager installation code will be added to the <header> and <body> sections of the website, so keep this tab open for easy access.
2. Copy and Add the Tracking Code
Now that your Google Tag Manager account is ready, the next step is to add tracking codes to the WordPress website.
You’ll need to copy the code snippets from the previous step and add the tracking code to the website’s header and body via its theme.
Important! Since the theme file is sensitive to changes, we recommend backing up your WordPress site beforehand. Once you have a backup of the website, don’t forget to download the backup files. Furthermore, we also recommend making these changes to a child theme instead of the parent theme to minimize the risk of breaking the site.
Follow these steps to copy and add the tracking code to a WordPress website:
- In a new tab, open the WordPress admin dashboard.
- Go to Appearance -> Theme Editor.
- On the right side of the window, locate header.php in the Theme Files navigation panel. Click to open it.
- Now, go back to the Google Tag Manager tab. Copy the Google Tag Manager code, then return to the WordPress tab.
- Locate the opening <head> tag and paste the tag manager code right after it.
- Now, copy the second part of the code snippet from the Google Tag Manager tab.
- Back on WordPress, locate the opening <body> tag. Paste the code immediately after it, as pictured below.
- Click the Update File button to save the changes.
Google Tag Manager has been successfully installed on your WordPress site and can be used to install any tracking code.
3. Publish a New Tag
Now it’s time to add and publish tags on your WordPress site.
Follow the steps below to add and publish a new tag on a WordPress site:
- Open your Google Tag Manager account, then navigate to the Workspace tab. Click the New Tag section.
- A new pop-up will appear. On its top-left corner, you’ll see an Untitled Tag field. Rename it with the desired tag name. In this example, we are adding a Google Analytics tag, so we’ll name it Site Analytics.
- On the Tag Configuration box, click on the big icon that says Choose a tag type to begin setup. In this example, we’ll choose Google Analytics – Universal Analytics.
- Under Track Type, expand the drop-down menu and choose one of the tracking types. We selected Transaction to track transactions.
- Under Google Analytics Settings, expand the drop-down menu and select New Variable. This will open the Variable Configuration window, where you’ll need to enter your Google Analytics tracking ID. Remember to name the variable as well. Click Save.
Since the Google Analytics tracking tag requires providing a Google Analytics tracking ID, you’ll need to create an account there first.
Once you have it, find the tracking ID in the Admin page’s Tracking Info section. A Google Analytics tracking ID typically looks like UA-1234567.
- Next, set up a trigger. Click on Choose a trigger to make this tag fire.
- The Choose a trigger pop-up will appear, showing several existing triggers. If you can’t find the desired option, click the + icon at the top-right corner.
- In the Trigger Configuration section, name the trigger and click Choose a trigger type to begin setup.
- You’ll see more trigger options. Here we selected Just Links under the Click section.
- On the Trigger Configuration box, check the options to apply in the tag. Under the This trigger fires on section, we selected All Link Clicks. Hit the Save button.
- Finally, it’s time to submit your newly created tag. On the Google Tag Manager dashboard’s Workspace tab, click the Submit button.
- To push changes to your site, select Publish and Create Version. Fill the Version Name field with the tag name and click Publish.
You have successfully installed a new Google Analytics tag on a WordPress site with Google Tag Manager.
If you’d like to see how the tag works on the actual site, click Preview on the Google Tag Manager dashboard. Once in the preview mode, reload the website, then perform the action that triggers the tag.
For example, if the tag is for tracking pageviews, you should see the tag fired on the Google Tag Manager console window once you reload the site.
Best Google Tag Manager Plugins for WordPress
You can also install Google Tag Manager in WordPress by installing plugins. This method requires less code-editing efforts and is more suitable for beginners.
Here are our recommendations for the three best Google Tag Manager plugins.
- Downloads: 500,000+
- Rating: 4.8/5.0
- Price: free
Google Tag Manager for WordPress is a plugin that complements your Google Tag Manager setup by pushing page metadata and user information into the data layer, providing necessary information to use in tags, triggers, or variables.
It helps optimize the site’s tag manager with features such as:
- Media players tracker – it tracks the use of popular embedded media players, such as YouTube and SoundCloud, which is particularly useful for musicians’ websites.
- Scroll tracking – it fires tags in Google Tag Manager containers based on scroll events, tracking how far visitors scroll through the pages.
To integrate Google Tag Manager using the plugin, you’ll need to provide a Google Tag Manager ID and choose your preferred container code placement.
The plugin’s default placement is Custom, requiring you to tweak the template file by pasting provided PHP code into it. The other options include Codeless injection, suitable for several website builders, and Off, which will just place the code according to Google’s recommendation and add a data layer to the page source.
Google Tag Manager for WordPress is a free plugin, so you can use all its features without a subscription.
- Downloads: 30,000+
- Rating: 4.7/5.0
- Price: free
Metronet Tag Manager integrates Google Tag Manager into your WordPress website, providing more control over the data layer, such as firing rules on almost any element.
Here are some of the features available in this plugin:
- Multiple predefined data layers – it provides six predefined data layer variables that are changeable and removable for system-testing purposes. These variables will be loaded on all posts and pages.
- Easy data layer addition – add as many data layer variables as necessary, both on a per-post and per-page basis.
- Additional HTML event handler and unique ID on WYSIWYG – add these elements to any content link using Google Tag Manager’s TinyMCE button in a WYSIWYG editor.
This plugin’s focus on providing more control regarding the data layer makes it stand out. Other GTM plugins usually require more data layer setup tasks, such as setting a variable before the tag manager script is loaded, or pushing an HTML event handler to the data layer when a button is clicked.
However, it is necessary to customize the GTM tag to implement this free plugin on a site.
Since WordPress doesn’t allow you to load scripts right after the opening tag, which is where the Google Tag Manager code needs to be placed, simply add <?php do_action( ‘body_open’ ); ?> right after the <body> tag.
- Downloads: 300,000+
- Rating: 4.9/5.0
- Price: free
To add Google Tag Manager on a WordPress website, you need to add its code to the head and body section of a theme’s HTML file.
However, some themes may use other names to refer to the header file, making it confusing for users to locate them.
This is where the Header and Footer plugin helps. It lets you simply copy the code and implement it in a site’s header, body, or footer – even if you don’t know where to find these sections.
This plugin’s features include:
- Custom code addition – add custom code to various locations, such as the head section of every blog webpage, only on the head section of the homepage, or before and after each post’s content.
- Theme independent – it allows changing the theme at any time without the risk of losing any injected code.
To integrate Google Tag Manager through this free plugin, navigate to Settings -> Header and Footer from your WordPress admin panel.
There, you’ll see a configuration panel with different location settings, such as <HEAD> PAGE SECTION ONLY ON THE HOMEPAGE.
Simply copy the Google Tag Manager installation code, paste the first part of the code to the <HEAD> PAGE SECTION panel, and place the second one in the AFTER THE <BODY> TAG panel.
Using Google Tag Manager on a WordPress site lets you manage, track, and deploy tags without editing each code snippet – all from a single dashboard. It also helps collect insights to improve your marketing efforts.
There are two ways to set up this tool – manually or by using a plugin. If you choose to go with a plugin, there are three Google Tag Manager plugins that we recommend:
- Google Tag Manager for WordPress – best for musicians and users who want to experiment with the container code placement.
- Metronet Tag Manager – best for users who demand more control over the data layer.
- Head, Footer, and Post Injection – best for beginners who are unsure where to place the installation code.
Now that you’ve learned how to use it, go ahead and install Google Tag Manager on your WordPress website.