How to Add Google Tag Manager Code in WordPress

How to Add Google Tag Manager Code in WordPress

Let’s face it—guessing what works on your website is like trying to play darts blindfolded. You might hit the target, but more often than not, you’ll just end up poking the wall.

That’s where Google Tag Manager comes in.

If you’ve ever asked yourself how to add Google Tag Manager code in WordPress, you’re in the right place. Whether you’re a marketer, blogger, or business owner, GTM can help you track user behavior without relying on a developer every time you want to test a script.

In this blog, we’ll break down GTM, why it matters, and the easiest ways to add it to your WordPress site—without breaking your site or your spirit.

What Is Google Tag Manager (GTM) Anyway?

Imagine GTM as your website’s remote control for tracking scripts. Instead of juggling 10 different snippets of code (one for Facebook Pixel, another for Google Analytics, a third for that random chat widget you forgot about), you get a central dashboard to manage them all.

Best of all? You don’t need to be a coding wizard to use it. GTM lets you:

  • Track clicks, form submissions, video views
  • Fire specific tags on certain pages
  • Integrate with Google Analytics 4, Facebook Pixel, LinkedIn Insight Tag, and more

Basically, it’s like giving your website a tracking Swiss Army knife—versatile, compact, and surprisingly powerful.

Before You Begin: A Few Must-Haves

Before we jump into how to add Google Tag Manager code in WordPress, here’s a quick checklist:

  • A working WordPress website (obviously)
  • Admin access to your dashboard
  • A Google account
  • Your favorite beverage (optional but recommended)

Method 1: Add Google Tag Manager Using a Plugin (The Easy Way)

For most beginners, this is the safest path forward. Here’s how to do it:

Step 1: Create Your GTM Account

Go to Google Tag Manager, sign in, and create a new account. Set your platform as “Web” and you’ll receive two code snippets—one for the <head> and another for the <body> section of your site.

Step 2: Install a Plugin

Choose one of the following:

  • Insert Headers and Footers
  • WPCode
  • Google Tag Manager for WordPress by DuracellTomi

Install and activate the plugin from the Plugins > Add New section in WordPress.

Step 3: Paste the Code

Head over to Settings > Insert Headers and Footers (or the appropriate plugin setting) and:

  • Paste the <head> code in the Header field
  • Paste the <body> code in the Body field

Save changes. Done!

Congratulations, you now know how to add Google Tag Manager code in WordPress without touching any core files.

Method 2: Add Google Tag Manager Manually (Advanced Users Only)

Warning: this method is not for the faint-hearted—or at least not for those afraid of breaking their theme.

Step-by-Step Guide:

  1. From your WordPress dashboard, go to Appearance > Theme File Editor
  2. Open header.php and paste the GTM <head> code right below the <head> tag
  3. Open footer.php or find where the <body> tag starts in your theme
  4. Paste the <body> GTM code right after the opening <body> tag
  5. Save the file and refresh your website

If you hear your heart racing, don’t worry—it’s completely normal when manually editing code. But now you can proudly say you’ve learned how to add Google Tag Manager code in WordPress the “old school” way.

How to Verify It’s Working

Use the Preview Mode inside your Google Tag Manager dashboard. When you visit your site, a debug panel will pop up at the bottom confirming which tags are firing. Or install the Tag Assistant Chrome extension.

Bonus: Setting Up Your First Tag (Like a Pro)

Let’s say you want to track all page views using GA4:

  1. Go to your GTM dashboard > Tags > New
  2. Choose Google Analytics: GA4 Configuration
  3. Paste your Measurement ID from Google Analytics
  4. Set the trigger as All Pages
  5. Save and click Submit

You just became a data-powered sorcerer. Or at least a savvy site owner.

Pro Tip: MonsterInsights for Even Simpler Tracking

Don’t want to tinker with GTM all day? Use MonsterInsights—a plugin that automatically sets up Google Analytics and common tracking events like:

  • Button clicks
  • Affiliate link clicks
  • File downloads
  • Scroll depth tracking

If GTM is a high-tech toolbox, MonsterInsights is the power drill.

Final Thoughts: Let GTM Work While You Sleep

Understanding how visitors interact with your site can reveal insights you never thought possible. Maybe that “Contact Us” button isn’t getting clicked. Maybe users are spending 10 seconds on your pricing page (yikes). You won’t know until you track.

By learning how to add Google Tag Manager code in WordPress, you’ve just unlocked a whole new level of control over your site’s performance. Whether you prefer the plugin path or manual method, what matters is that you’re now running on data—not guesswork.

Need Help Setting It Up?

At SE Rank Pro, we’re a trusted digital marketing company in Chandigarh that helps businesses grow through smarter analytics, SEO, and data-driven design. If adding tags and tracking user behavior feels like learning Latin, let us take care of it while you focus on what you do best—running your business.

Get in Touch with Us

Have any questions or want to learn more about our SEO services? Feel free to reach out. We’re here to help!