The Complete Guide to Installing and Using Google Tag Manager in WordPress (2023)

Hey there, WordPress user! Are you looking to level up your website tracking and analytics game? Want to easily add and manage tracking tags without editing code? Then it‘s time to dive into Google Tag Manager.

Google Tag Manager (GTM) is a powerful free tool that makes it simple to add and control various tracking codes on your WordPress site. Rather than pasting snippets directly into your WordPress files, GTM acts as a central hub to manage all your tags in one web-based interface.

Over 49% of the top 100,000 websites use Google Tag Manager to streamline their tracking setup. And for good reason! GTM empowers marketers to quickly deploy tags for conversion tracking, site analytics, remarketing, and more—without having to rely on developers.

In this complete guide, we‘ll walk you through everything you need to know to install Google Tag Manager on WordPress and start taking advantage of its awesome features. We‘ll cover:

  • Why use Google Tag Manager with WordPress?
  • Step-by-step GTM setup and installation on WordPress
  • Adding your first tags and triggers
  • Advanced tracking with GTM (click tracking, form submissions, scroll depth, etc.)
  • Comparing GTM with MonsterInsights for WordPress analytics

Sound good? Let‘s get tracking!

Why Use Google Tag Manager with WordPress?

So what makes Google Tag Manager so great for WordPress websites? Here are a few key benefits:

1. Manage all your tags in one place

The main advantage of GTM is being able to manage all your tracking codes in a single dashboard. Rather than dealing with dozens of code snippets across various plugins and theme files, GTM acts as your central hub. This makes it way easier to add, edit, and remove tags as needed.

2. Add and update tags without coding

With GTM, there‘s no need to manually edit code every time you want to adjust your tags. Non-technical users can log into the GTM dashboard and make changes with just a few clicks. This saves a ton of time and reduces the risk of accidentally breaking your site.

3. Boost website speed and performance

Having a bunch of tracking codes firing on your site can slow down your page load times. GTM helps solve this by loading scripts asynchronously and minimizing the number of requests. Faster loading means better SEO and happier visitors!

4. Enable advanced tracking and events

GTM makes it easy to set up advanced tracking that goes beyond basic page views. You can track events like button clicks, video plays, form submissions, scrolling behavior, and more. This granular data gives you deeper insights into how people interact with your WordPress site.

5. Test and debug tags before pushing live

GTM includes handy testing and debugging tools so you can make sure everything works before publishing. The preview mode lets you see which tags are firing on your site in real-time. And version control makes it easy to roll back changes if something breaks.

Case study: MonsterInsights increased conversions by 30% after implementing GTM event tracking for form submissions and button clicks on their WordPress site.

How to Install Google Tag Manager on WordPress (Step-by-Step)

Ready to experience the magic of GTM on your WordPress site? Follow along with this step-by-step guide.

Step 1: Set up Google Tag Manager

First, you‘ll need a Google Tag Manager account. If you don‘t have one yet, sign up for a free account. You‘ll be prompted to create a new GTM container for your website:

Set up a new GTM account and container

Be sure to select "Web" as your target platform. You can have multiple containers if you need to track different environments (like staging vs production). But for most WordPress sites, one container is fine.

Step 2: Add the GTM container snippet to WordPress

After setting up your GTM container, you‘ll get two chunks of code to add to your WordPress site:

GTM container code snippets

  • The first script goes in the <head> tag of your site
  • The <noscript> goes right after the opening <body> tag

There are a few ways you can add these code snippets to WordPress:

Option 1: Install a WordPress plugin

By far the easiest method is to use a dedicated plugin. We recommend the free Insert Headers and Footers plugin.

After installing the plugin, go to Settings > Insert Headers and Footers in your WordPress admin. Then just paste the GTM codes into the relevant boxes:

Adding GTM code with Insert Headers and Footers plugin

Option 2: Edit your WordPress theme

If you‘re comfortable editing your WordPress theme files, you can add the GTM code snippets directly. The <head> code goes in your theme‘s header.php file, while the <body> code goes in footer.php.

We only recommend this method if you‘re familiar with coding and have a child theme set up. Otherwise, your GTM installation could get overwritten when you update your theme.

Step 3: Test your GTM installation

After adding the GTM snippets to your WordPress site, you‘ll want to test that everything is working correctly.

In your GTM workspace, click the Preview button in the upper right corner. This will put GTM into debugging mode, where you can see which tags are firing on your site in real-time.

Open your WordPress site in a new tab and browse around. You should see a GTM debug panel at the bottom of the screen that shows your container ID and which tags are firing:

GTM preview and debug mode

If you see the debug panel on your WordPress site with no errors, congrats! GTM is now successfully installed and ready for you to start configuring tags.

Setting Up Your First Tag in Google Tag Manager

Now for the fun part—adding tags to track data on your WordPress site. Let‘s start with a basic example: tracking page views with Google Analytics.

Step 1: Create a new tag

In your main GTM workspace, click the Add a New Tag button.

Choose a name for your tag that describes what it does, e.g. "Google Analytics – Pageview".

Step 2: Configure the tag type

Click on the Tag Configuration box to choose your tag type. To track page views, select the "Universal Analytics" tag under the Google Analytics section:

Universal Analytics tag type

Configure the tag with the following settings:

  • Track Type: Page View
  • Google Analytics Settings: Create a new variable and enter your Google Analytics tracking ID (looks like UA-xxxxxx-x)

Step 3: Set up a trigger

For your tag to fire, you need to set up a trigger that tells GTM when to track data. Since we want to track all page views, we‘ll use the built-in "All Pages" trigger.

Under Triggering, click the plus icon in the top right. Select the "All Pages" trigger to track every page on your site by default.

Step 4: Save and publish

Click the Save button to create your tag. But before it starts collecting data, we need to push it live.

Click the Submit button and enter a version name that describes your change, e.g. "Added Google Analytics page view tracking".

Hit Publish and you‘re done! Page views will now be tracked in both Google Analytics and GTM.

Advanced WordPress Tracking with Google Tag Manager

While tracking page views is a good start, the real power of GTM comes from its ability to track all sorts of user events and interactions. Here are a few examples of advanced tracking you can set up for deeper insights.

Track Link Clicks

Want to see which links on your WordPress site get the most clicks? GTM makes it easy to track all your link clicks automatically.

In your GTM workspace, create a new trigger and select "Just Links" as the trigger type. Choose "Some Link Clicks" and set the condition to "Page URL matches RegEx .*" to track links on all pages:

Just Links GTM trigger

Then create a new Google Analytics event tag with the following settings:

  • Track Type: Event
  • Category: Link Click
  • Action: {{Click URL}}
  • Label: {{Page URL}}

For the trigger, choose the Just Links trigger you created above. Now GTM will record an event in Google Analytics every time someone clicks a link, along with the link URL and page URL.

Track Form Submissions

Forms are a critical conversion point on most WordPress sites. If you‘re using a popular form plugin like Gravity Forms or Contact Form 7, they likely have built-in GTM event tracking. Just enable the integration in the plugin settings.

If your form plugin doesn‘t have native GTM support, you can track form submissions manually. First create a new trigger in GTM:

GTM form submission trigger

  • Trigger Type: Form Submission
  • Event: Some Forms
  • Condition: Page URL matches RegEx .*

Then set up a Google Analytics event tag with the following settings:

  • Track Type: Event
  • Category: Form Submission
  • Action: {{Form ID}}
  • Label: {{Page URL}}

Use the Form Submission trigger you just created. This will log an event whenever a form is submitted with the form ID and page URL.

Track Scroll Depth

Seeing how far users scroll on your WordPress posts and pages provides valuable insights into content engagement. GTM‘s built-in scroll depth trigger makes this tracking easy to set up.

Create a new trigger in GTM and choose "Scroll Depth" as the trigger type. Configure it to track vertical scroll depths at certain thresholds, e.g. 25%, 50%, 75%, and 100%.

Then create a Google Analytics event tag using the scroll depth trigger with these settings:

  • Track Type: Event
  • Category: Scroll Depth
  • Action: {{Scroll Depth Threshold}}
  • Label: {{Page URL}}

Now you‘ll see events in Google Analytics for each scroll threshold reached.

Using MonsterInsights vs. Google Tag Manager for WordPress Tracking

We‘ve covered several powerful ways to track WordPress user behavior with Google Tag Manager. But what if GTM feels a bit too technical or time-consuming?

If you‘re looking for an easier solution, we highly recommend the MonsterInsights plugin. It‘s the most popular Google Analytics plugin for WordPress with over 3 million active installs.

MonsterInsights lets you enable advanced tracking features with just a few clicks—no coding or complicated GTM setup required. Some of the tracking events MonsterInsights can handle automatically include:

  • Link and button click tracking
  • Form submission tracking
  • Scroll depth tracking
  • File download tracking
  • Outbound link tracking
  • And more

The plugin also offers enhanced eCommerce tracking for WooCommerce and Easy Digital Downloads. Plus, the handy MonsterInsights dashboard reports let you view key metrics without leaving your WordPress admin:

MonsterInsights dashboard

To be clear, Google Tag Manager is an excellent tool with robust functionality. But if you want to enable tracking more quickly, MonsterInsights is a great option for WordPress users.

Wrapping Up

Congratulations! You now have all the knowledge you need to install Google Tag Manager on WordPress and start tracking valuable user insights. Let‘s recap the key steps:

  1. Sign up for a free GTM account and create a web container
  2. Add the GTM container code snippets to WordPress using a plugin or editing your theme files
  3. Verify your GTM installation with preview and debug mode
  4. Create your first page view tag to track Google Analytics data
  5. Set up advanced tracking like link clicks, form submissions, and scroll depth
  6. Consider MonsterInsights as a user-friendly, code-free alternative to GTM

By leveraging GTM‘s powerful event tracking, you can gain a deeper understanding of how people interact with your WordPress site. This data empowers you to make smarter optimizations and drive more conversions.

Now it‘s your turn—go forth and start tracking with GTM! And if you found this guide helpful, be sure to subscribe to our newsletter for more juicy WordPress tips.

Did you like this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.