how to install tag manager in wordpress

How to Install Google Tag Manager in WordPress [2024]

Are you wondering how to install Google Tag Manager in WordPress?

Google Tag Manager is a useful tool for connecting multiple analytics and marketing platforms to your WordPress site and setting up different Google Analytics event tracking features. It allows you to add and update tracking codes and code snippets on your website easily.

However, Google Tag Manager has a pretty high learning curve. Once you install it on WordPress, you’ll have to spend time learning how to use it correctly. If you set it up incorrectly, you could mess up your data.

Want a MUCH easier way to set up advanced Google Analytics tracking? In addition to showing you how to install GTM, I’ll also cover a Google Tag Manager alternative that makes it super simple to set up multiple different tracking features for your WordPress website.

MonsterInsights is the best WordPress Analytics plugin. Get it for free!

Install GTM in WordPress: Video Walkthrough

What is Google Tag Manager?

Google Tag Manager (GTM) is a free tool by Google that allows users to manage and deploy marketing tags (snippets of code or tracking pixels) on their website or app without modifying the code directly. GTM enables efficient tracking of user behavior and simplifies the process of integrating third-party tools like analytics and advertising platforms.

Different tracking services like Google Analytics, Adobe Analytics, Facebook Pixel, and advertising tools like Google Ads require you to add a few lines of JavaScript or HTML code to your website to integrate their services.

With Google Tag Manager, you can easily add and manage all these code snippets from a single dashboard without having to edit your website’s code.

Besides adding these tracking snippets, Google Tag Manager also helps you add snippets of code that tell Google Analytics to track events on your website that it doesn’t track out of the box, like eCommerce, link clicks, form submissions, and more.

While that sounds fairly simple, the different tags and triggers you’ll have to add to set those things up can get really complicated, and the tutorials are rather long.

An Easier Way to Set Up Advanced WordPress Tracking

While Google Tag Manager is a powerful tool (and we’ll talk about how to set it up in a moment), it’s not the best for beginners and has a pretty big learning curve. Luckily, there’s an easier alternative to setting up many of the tracking features you might use it for in WordPress.

With MonsterInsights, you can set up advanced tracking and get features like eCommerce tracking, link and button click tracking, form conversion tracking, scroll tracking, and much more out of the box. You can even track Google Ads conversions on an eCommerce website without having to touch any code. Simply turn on these features with a few clicks in MonsterInsights rather than go through a complicated Tag Manager setup.

Now, we’ll cover both how to add Google Tag Manager to WordPress with MonsterInsights and show you how to install GTM without MonsterInsights. You can click the links below to jump ahead to any section you’re interested in:

Set Up Advanced Tracking in WordPress the Easy Way

MonsterInsights is the best alternative to Google Tag Manager. It’s easier to use, and you don’t have to spend hours learning how to use It.

MonsterInsights Home Dashboard

Instead of manually setting up tags and triggers to track different interactions with your website, you can just click a button to turn it on. Not only that, but using MonsterInsights also removes any risk of making a mistake and messing up your tracking code.

MonsterInsights provides advanced features right out of the box. It also allows you to set up Google Analytics on a WordPress site without editing code.

So, what makes MonsterInsights a great alternative to Tag Manager? Let’s look at some of the reasons why you should use MonsterInsights instead.

1. Track Link and Button Clicks Out of The Box

Google Analytics doesn’t track most link clicks or button clicks by default. You would have to manually set up tracking for each link and button using Google Tag Manager or by adding a piece of code to your website.

But with MonsterInsights, you can track a lot of link clicks without any extra work. There’s no need to set up additional tracking tags or edit code. Here are some of the things you can track:

2. Set Up Form Conversion Tracking

If you have one or more forms on your website, like a Contact Us form and an order form, you’ll want to see how they’re performing. Although GA4 tries to track your forms out of the box with its enhanced measurement feature, it has some serious flaws that make it unreliable.

Without MonsterInsights, you would have to create tags for each contact form using Google Tag Manager so that Google Analytics can accurately track their performance.

MonsterInsights, on the other hand, makes this process super simple. All you have to do is install its Forms addon, and the plugin will automatically track all types of WordPress forms.

The best part is that you can view the performance of your forms inside the WordPress dashboard. Just go to Insights » Reports » Forms to find out the number of impressions, conversions, and conversion rates of all your forms.

MonsterInsights Forms Report

You can also identify the source of your form conversions and see which channels help capture the most leads.

3. Track eCommerce Performance in Just a Few Clicks

Another advantage of using MonsterInsights is that you can enable eCommerce tracking in just a few clicks to track how your online store is performing.

Using the eCommerce addon, it’s very easy to track revenue, conversion rate, popular products, conversion sources, coupons, and much more in Google Analytics. MonsterInsights integrates directly with WooCommerce, Easy Digital Downloads, GiveWP, MemberPress, and more.

MonsterInsights eCommerce Report - GA4

It also helps you understand your customers’ behavior. You can see which pages they visit, how many products they add to and remove from the cart, and how many abandoned their carts.

Plus, you can use the User Journey addon to see what paths your users take through your site to get to their purchase:

User Journey by MonsterInsights - Customer Journey Analytics

For more on eCommerce tracking and reporting, check out Google Analytics 4 eCommerce Tracking Tutorial [WordPress].

4. Install Ad Conversion Tracking Codes & Pixels

If Google Ads, Bing Ads, or Meta (Facebook) Ads are part of your digital marketing playbook, MonsterInsights has you covered for conversion tracking. Simply copy and paste your conversion ID and conversion label, tag ID, or pixel ID right into your MonsterInsights settings.

MI PPC Ads Tracking Settings

Learn more about ad tracking in these articles:

How to Set Up eCommerce Google Ads Conversion Tracking
Tutorial: Bing Conversion Tracking in WordPress [Microsoft Ads]
How to Track Meta (Facebook) Ads in Google Analytics Easily

5. Chat With Your Google Analytics Data

Have a question you need to answer about your analytics? With Conversations AI by MonsterInsights, all you have to do is ask. It’s like having a personal analytics assistant right in your WordPress dashboard!

Ask about your landing pages, sales, engagement, and much more to get your answers quickly. It can even generate a unique graph based on your data.

Ready to skip setting up Google Tag Manager and track events the easier way?

Set up Google Analytics Tracking the Easier Way

Set Up WordPress Google Tag Manager in 3 Steps

To add Google Tag Manager to WordPress without using MonsterInsights, just follow these steps to get started.

Step 1: Create Your Google Tag Manager Account

First of all, you need to visit the Google Tag Manager home page and then click the Sign-Up button.

Sign Up for Google Tag Manager

Next, you need to sign in with your Google account. Once done, you can see the Google Tag Manager’s Create Account page. Click on the Create Account button to get started.

Create Google Tag Manager Account

On the next screen, you can add a new account. Enter your account name and choose a country in the Account Setup box. You can use your company name as your account name.

Add New Google Tag Manager Account - Account Setup

Next, you need to set up your container. A container is the collection of tags, triggers, and all configurations installed on a website.

You can enter your website name as your container name. Choose Web under the Target platform container option, and then click on the Create button.

Google Tag Manager Container Setup

Now, you’ll need to accept the Google Tag Manager Terms of Service Agreement to proceed. Check the box 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.

If you want to learn more about GDPR, go through our guide on GDPR and Google Analytics.

Accept Google Tag Manager Terms of Service and GDPR terms

Upon accepting the terms of service, you’ll see a new popup window appear on the screen with the GTM code snippets you’ll need to install on your website.

Your JavaScript tag that needs to be installed in your header will look like this:

<!– Google Tag Manager –>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
‘https://www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,’script’,’dataLayer’,’GTM-XXXXXX’);</script>
<!– End Google Tag Manager –>

Whereas the tag that needs to go in the body section immediately after your opening body tag will look like this:

<!– Google Tag Manager (noscript) –>
<noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX”
height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
<!– End Google Tag Manager (noscript) –>

Google Tag Manager Installation Instructions - WordPress

Step 2: Add Google Tag Manager Code to WordPress

Login to your WordPress admin and then install the free version of the WPCode plugin. Upon activation, go to Code Snippets » Header & Footer page.

WPCode is the best WordPress plugin for adding code snippets and GTM container code to your website without having to edit any site files.

WPCode Header and Footer

Now, you can see a box for adding code to your header, without having to touch your header.php file. Go back to your Google Tag Manager account and copy the code in the first box. Paste the code into the Header box.

Then, copy the other code from your Tag Manager account and insert that into the Body box.

Install Google Tag Manager in WordPress

After that, don’t forget to save your changes.

That’s it! You’ve successfully installed Google Tag Manager on your WordPress site. Now you can use your Google Tag Manager dashboard to install any tracking code to your WordPress website.

Step 3: Add and Publish Tags in Your Tag Manager

Once you’ve installed Google Tag Manager on your website, you’re ready to add code snippets (tags) provided by different tracking tools on your site.

Google Tag Manager supports over 50 tag types, including Google marketing products and other third-party services. Plus, you can also add custom HTML or JavaScript tags to your site using its interface.

To create and add a tag, click on the New Tag tile, and follow the steps to create your first tag.

Click New Tag Option to Add a New Code in Google Tag Manager

For example, you can check out our full guide on installing Google Analytics in WordPress with Google Tag Manager.

You can now add different tags in your Google Tag Manager container by following the same process and integrating your WordPress site with various marketing and tracking tools.

WordPress Google Tag Manager FAQ

What is the best GTM plugin for WordPress?

MonsterInsights is the best plugin to use for Google Tag Manager tracking in WordPress. You can actually use it as an alternative to Google Tag Manager because it tracks many events for you without having to go through a complicated GTM setup.

If you just need to install the Google Tag Manager tracking code, then WPCode is the best plugin for that.

Other Google Tag Manager plugins for WordPress include GTM4WP and Google Site Kit.

Where do I put the Google Tag Manager code in WordPress?

Add the WPCode plugin to WordPress, then insert your Google Tag Manager code into the Header section and Body section, following the Tag Manager instructions.

Or, install MonsterInsights to avoid needing to use Google Tag Manager at all!

Why not use Google Tag Manager?

Google Tag Manager is a code injection tool, which can sometimes cause security vulnerabilities on your site. It’s also a tool that really takes time to learn, and is pretty confusing for beginners. If you want to bypass using Google Tag Manager altogether, take a look at MonsterInsights. It sets up a lot of the tracking that you might use Google Tag Manager for in just a couple of clicks!

Does the Google Site Kit plugin install Google Tag Manager?

Yes, Google Site Kit can help you install Google Tag Manager on your WordPress site. However, it doesn’t provide any further setup help or conversion reports in your WordPress dashboard. For more on Site Kit, check out MonsterInsights vs. Google Site Kit.

And that’s it!

We hope this article helped you learn how to install Google Tag Manager correctly in WordPress.

If you liked this tutorial, here are a few more articles you might want to check out:

How to Add Google Search Console to WordPress and Analytics
How to Add Google Analytics 4 (GA4) to Google Tag Manager
How to Set up Google Analytics Click Tracking (Step by Step)
How to Add a Meta (Facebook) Pixel to Google Tag Manager

Still not using MonsterInsights? What are you waiting for?

And don’t forget to follow us on YouTube for more helpful tutorials, reviews, and Google Analytics tips.

Want to Try MonsterInsights for Free?

Enter the URL of Your WordPress website to install MonsterInsights Lite.

Comments

  1. WPcode adds the code close to the bottom of the section. Is there a way to add the code higher up with WPcode plugin. Or my only workaround to get the code higher is just adding it directly to the code?

    1. Hi Amy – Yes, it can still be possible to also use MonsterInsights alongside GTM as long as you avoid including any pageview triggers or custom events (such as downloads tracking) that MonsterInsights automatically tracks in any of the tags attached to your active container. Multiple pageview or event hits of the same thing can unintentionally skew your Analytics data.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.