Did you know that nearly half of all websites use Google Tag Manager to enhance their tracking capabilities?
It allows you to easily add and manage multiple tracking codes like Google Analytics, conversion tracking, and remarketing tags without editing your website’s code manually.
But struggling to install Google Tag Manager on WordPress and can’t find a way around it?
If so, your website might be missing out on the opportunity to meet the 99.7% market standard for optimizing site performance and tracking accuracy.
But don’t worry—we’ve got a solution for you!
In this step-by-step guide, we’ll walk you through everything you need to know about adding GTM to WordPress. By the end, you’ll know how to set it up in multiple ways, and you’ll be able to choose the method that works best for your site.
Get in touch to learn about Analytico’s Digital Analytics Audit services or GA4 audit services.
Google Tag Manager Overview?
Before diving into the process of GTM installation, let’s briefly discuss what Google Tag Manager is.
Google Tag Manager is a free tool provided by Google that allows you to manage marketing and analytics tags (snippets of code) on your website or mobile app.
These tags help track user interactions, events, and conversions without requiring constant updates to your website’s backend.
In simple terms, GTM adds or updates tracking codes quickly and effortlessly, which enhances your site’s functionality and performance.
Why Should You Use Google Tag Manager in WordPress?
Adding GTM to WordPress provides multiple benefits, such as:
- Simplified Code Management:
You can manage and deploy various tags (Google Analytics, Google Ads, Facebook Pixel, etc.) without manually adding code to each page.
- Faster Site Updates:
You can add or edit tags through the GTM dashboard instead of accessing WordPress files, making the process faster and safer.
- Improved Website Performance:
By managing all your tags in one place, you avoid slow load times and potential conflicts caused by manually adding multiple scripts.
- Enhanced Tracking:
You can track specific user actions like button clicks, form submissions, video views, and more using event tracking in GTM.
With these benefits in mind, let’s walk through the steps to install Google Tag Manager on WordPress.
Adding GTM to WordPress
Step 1: Create a Google Tag Manager Account
To start, you need a Google Tag Manager account. If you don’t have one, follow these steps to create one:
- Go to the Google Tag Manager website (https://tagmanager.google.com).
- Sign in with your Google account.
- Click “Create Account”, then enter your account name and country.
- Set up the container by entering your website URL and selecting “Web” as the target platform.
- Click “Create”, accept the terms, and your account will be set up.
Once your account is ready, Google will provide you with a GTM container code. You’ll need to copy this code, as it is essential for installing Google Tag Manager on WordPress.
Step 2: Install Google Tag Manager in WordPress
There are several ways to add Google Tag Manager to WordPress, including manually pasting the code, using a plugin, or using WordPress themes.
Let’s go through these methods step-by-step.
Method 1: Manually Add GTM Code to WordPress
You can manually add Google Tag Manager code into the WordPress theme if you prefer a hands-on approach. This method requires you to add code to your theme’s header and body sections.
Follow these steps:
- First, you have to log in to your WordPress dashboard.
- Then navigate to Appearance > Theme File Editor.
- Select your theme’s header.php file from the list of theme files.
- Paste the GTM code you copied earlier:
- The first part of the code (the <script> tag) should go right after the <head> tag.
- The second part (the <noscript> tag) should be placed right after the opening <body> tag.
- Click “Update File” to save the changes.
While this method works, it’s risky because changes to your theme files can be lost when you update your theme. For beginners, we recommend using a plugin instead.
Method 2: Use a Plugin to Add Google Tag Manager to WordPress
Using a plugin is a much safer and easier way to install Google Tag Manager in WordPress. This method doesn’t require modifying theme files, and you won’t lose your GTM setup when updating the theme.
Here’s how to do it using the Insert Headers and Footers plugin:
- Go to your WordPress dashboard and click on Plugins > Add New.
- In the search bar, type “Insert Headers and Footers”.
- Install and activate the plugin.
- Once activated, navigate to Settings > Insert Headers and Footers.
- Paste the GTM code into the Scripts in the Header section (for the first part) and the Scripts in the Body section (for the second part).
- Click “Save” to apply the changes.
This plugin-based approach ensures you can add, manage, and update tags without modifying your theme files directly.
Method 3: Use a Google Tag Manager Plugin
Another option is to use a dedicated Google Tag Manager WordPress plugin. Several plugins are specifically built to integrate GTM with WordPress. These plugins automatically add the GTM code to your site’s header and body sections.
Here’s how to do it using DuracellTomi’s Google Tag Manager for WordPress plugin:
- Go to Plugins > Add New in your WordPress dashboard.
- Search for DuracellTomi’s Google Tag Manager for WordPress and click Install.
- Once installed, click Activate.
- Navigate to Settings > Google Tag Manager.
- Enter your GTM Container ID (found in your Google Tag Manager account) into the plugin settings.
- Save the changes, and GTM will be integrated into your WordPress site.
This method is ideal for beginners because it automates the setup and reduces the risk of errors.
Step 3: Verify the Google Tag Manager Installation
After successfully adding Google Tag Manager to WordPress, you need to verify that the setup works well.
There are several ways to check if GTM is installed correctly:
- Google Tag Assistant:
Install the Google Tag Assistant Chrome extension to check if the GTM code is firing correctly on your site.
- Preview Mode:
Go to your Google Tag Manager dashboard and enable Preview Mode. Then, visit your website to see which tags are being triggered.
- View Source Code:
In your browser, right-click your website and select “View Page Source.” Search for “GTM-” to confirm that the GTM code has been added to the header and body sections of your site.
Common Mistakes to Avoid When Installing GTM in WordPress
While adding Google Tag Manager to WordPress is relatively straightforward, it’s important to avoid common pitfalls that can interfere with proper setup.
- Not Pasting the Code in the Correct Sections:
The first part of the GTM code should be in the header, and the second part should be in the body. Misplacing these can cause tracking errors.
- Theme Updates Overwriting Code:
If you manually add the GTM code, updating your theme could overwrite it. Always double-check after updates.
- Using Multiple GTM Containers:
Avoid adding multiple GTM containers to your website, as it can lead to tracking conflicts.
- Skipping Verification:
After adding GTM, always verify the setup using tools like Google Tag Assistant to ensure your tags are firing correctly.
Additional Best Practices for Using Google Tag Manager
Once GTM is installed on your WordPress site, follow these best practices to make the most out of it:
- Organize Your Tags:
Use clear naming conventions for your tags, triggers, and variables to avoid confusion when managing multiple tags.
- Test Your Tags:
Always use Preview Mode or Tag Assistant to test your tags before publishing them.
- Keep Track of Versions:
Google Tag Manager allows you to create versions of your container, which can be useful when troubleshooting or rolling back changes.
- Use Built-In Tags:
Google Tag Manager has several built-in tag templates for Google Analytics, Google Ads, and more. Use these to simplify the tag creation process.
Conclusion
Installing Google Tag Manager on WordPress is a crucial step for optimizing your website’s tracking and improving data insights.
Whether you choose to manually add the code, use a plugin, or opt for a dedicated GTM plugin, you now have the tools to implement GTM in your WordPress site with confidence.
By following the steps outlined in this guide, you’ll ensure that your GTM WordPress installation is both accurate and efficient, giving you better control over your site’s marketing and analytics tools.
Remember to periodically check and update your tags to maintain your site’s performance.
If you’re still wondering whether you should install Google Tag Manager in WordPress, the answer is a resounding yes. This powerful tool simplifies tracking, boosts website performance, and saves you time when managing multiple tags.
Do you like what you read? Learn more about Digital Analytics on our blog here.