Google Tag Manager (GTM) makes it easy to manage and deploy tracking codes — like Google Analytics, Facebook Pixel, Hotjar, or custom events — all from one dashboard without touching your site’s code every time.
Here’s how to set up Google Tag Manager in WordPress quickly and safely.
🧠 What You’ll Need
- A free Google Tag Manager account
- Access to your WordPress site (admin)
- Optional: Google Analytics or other tags you want to manage
✅ Step 1: Create a Google Tag Manager Account
- Go to https://tagmanager.google.com
- Click Create Account
- Fill in:
- Account Name (your business or site name)
- Container Name (your site’s domain)
- Choose Target Platform: Web
- Click Create and accept the terms
🎉 GTM will now give you two code snippets (Head and Body). You’ll need these in the next step.
✅ Step 2: Add GTM to Your WordPress Site
🔌 Option 1: Use a Plugin (Recommended)
Best Plugin: Insert Headers and Footers (or WPCode)
- Go to Plugins > Add New
- Search for Insert Headers and Footers or WPCode
- Install and activate
- Go to Settings > Insert Headers and Footers
- Paste:
- GTM Head code into the Header section
- GTM Body code into the Body section (if supported by plugin)
- Click Save
🛑 Note: Some plugins only support <head>
. For full GTM support (especially triggers like scroll or form events), use a plugin that supports body placement too (like WPCode Pro or manually edit the theme).
🔧 Option 2: Manually Add to Theme (Advanced)
⚠️ Only use this method if you’re using a child theme. Updates to your theme may overwrite manual changes.
- Open
header.php
in your child theme - Paste the GTM head snippet just after the
<head>
tag - Open
footer.php
orbody-open.php
(depending on theme) - Paste the GTM body snippet right after the
<body>
tag
✅ Step 3: Test if GTM is Working
- Go to https://tagassistant.google.com/
- Enter your site URL and click Connect
- Open your website in the new tab
- Return to Tag Assistant – it should show that GTM is firing correctly
🎯 If it’s not, double-check:
- Code placement
- Plugin settings
- Cache (clear your site + browser cache)
✅ Step 4: Add Tags via Google Tag Manager
Now you can:
- Add Google Analytics 4
- Install Facebook Pixel
- Track form submissions, button clicks, scroll depth, etc.
- Run A/B tests with tools like Optimize
No more editing code — just publish new tags from GTM’s dashboard.
🧠 Pro Tips
- Name your tags clearly (e.g., “GA4 – All Pages”)
- Use preview mode before publishing new tags
- Combine GTM with Google Consent Mode for GDPR compliance
📦 Final Thoughts
Setting up Google Tag Manager in WordPress is a one-time job that saves you hours down the line. For most users, using a plugin like Insert Headers and Footers or WPCode is the fastest, safest way to get started.
Need help setting up GA4, event tracking, or tag firing rules? WPWise can guide you — just drop a question below.