Tracking visitor behaviour on your WordPress site starts with the right setup. Google Tag Manager gives you control over how tracking works on your site — but only if it is installed correctly. A missed step or incorrect configuration at the start can compromise your data later, making it harder to measure effectiveness and make informed decisions. Installing GTM correctly on WordPress is one of the most important foundational steps for anyone serious about understanding their site's performance.
Key Takeaways
- Installing Google Tag Manager on a WordPress site centralises all tracking codes — including Google Analytics and Facebook Pixel — in a single control panel;
- It allows users to add, update or remove tags without editing theme files or relying on multiple plugins;
- Correct setup and verification ensure accurate data collection and reduce site errors.
What Is Google Tag Manager?
Google Tag Manager (GTM) is a free tag management system from Google that lets you manage your website's tracking codes from a single control panel. A tag is a small code snippet used for analytics, advertising or conversion tracking — such as the Google Analytics tag or Facebook Pixel. Without GTM, every tag must be added manually to your WordPress theme files — a time-consuming, error-prone process. GTM simplifies this: you add one container code to your site, then manage all tags from the GTM interface. This approach improves efficiency, reduces the risk of errors and makes it easy to scale tracking across multiple tools.
What You Will Need Before Starting
- A Google account (a free Gmail account is sufficient);
- WordPress admin access;
- A publicly accessible WordPress site (not in maintenance mode or password-protected);
- A child theme (only for the manual installation method).
Create Your GTM Account and Container
Step 1: Go to Google Tag Manager
Visit tagmanager.google.com and sign in with your Google account.
Step 2: Create a New Account
Click "Create Account". Enter an account name (your business name), select your country and choose whether to share data anonymously with Google.
Step 3: Set Up Your Container
Enter your website URL as the container name, select "Web" as the target platform, and click "Create".
Step 4: Accept the Terms of Service
Review and accept the Google Tag Manager Terms of Service.
Step 5: Copy the GTM Code Snippets
After accepting the terms, two code snippets appear. Keep this window open — you will need these in the next steps. Snippet 1 goes in the <head> section; Snippet 2 goes immediately after the opening <body> tag.
Method 1: Using the GTM4WP Plugin (Recommended)
The GTM4WP plugin is the easiest and most reliable method. It automatically handles code placement and sends additional data (post titles, categories, author information) to the GTM data layer for more advanced tracking.
- Go to Plugins → Add New, search for "GTM4WP", install and activate.
- Go to Settings → Google Tag Manager.
- Enter your GTM Container ID (format: GTM-XXXXXXX).
- Set the container code placement to "Footer" and save settings.
- In GTM, click "Submit" to publish your container — this activates the tracking on your live site.
Method 2: Using the WPCode Plugin
- Install and activate the WPCode plugin.
- Go to Code Snippets → Header & Footer.
- Paste GTM Snippet 1 into the "Header" field.
- Paste GTM Snippet 2 into the "Body" field.
- Save changes.
- Publish your GTM container.
Method 3: Manual Installation via Theme Files
Important: Only do this with a child theme active — changes to a parent theme are lost when the theme updates.
- Ensure your child theme is active.
- Go to Appearance → Theme File Editor.
- Open header.php in your child theme.
- Paste Snippet 1 immediately after the opening
<head>tag. - Paste Snippet 2 immediately after the opening
<body>tag. - Save changes.
- Publish your GTM container.
How to Verify GTM Is Working
- In GTM, click "Preview" in the top right.
- Enter your website URL in the Tag Assistant window and click "Connect".
- Browse your site — Tag Assistant should show "Google Tag Manager" as connected and list tags that fired.
- Exit Preview mode when verification is complete.
Troubleshooting
If GTM is not appearing in Tag Assistant: verify the container ID is correct; check that the code is in the right location (before </head> for Snippet 1); disable caching plugins temporarily and retest; check if a security plugin is blocking the GTM script.
Adding Your First Tag: Google Analytics 4 (GA4)
- In GTM, go to Tags and click "New".
- Name your tag (e.g. "GA4 — All Pages").
- Click "Tag Configuration" and select "Google Tag" (for GA4).
- Enter your GA4 Measurement ID (format: G-XXXXXXXXXX).
- Click "Triggering" and select "All Pages" as the trigger.
- Save and click "Submit" to publish.
Common Mistakes to Avoid
- Installing GTM code directly in a parent theme (lost on theme updates);
- Forgetting to publish the GTM container after making changes (changes in GTM are not live until published);
- Installing both GTM and direct GA4 tracking code — this results in double-counting;
- Not verifying the installation before going live;
- Using incorrect container ID (copy it directly from GTM, not from memory).
Conclusion
Installing Google Tag Manager on WordPress is a straightforward process when you follow the right steps. The GTM4WP plugin method is recommended for most users due to its simplicity and the additional data layer functionality it provides. Once GTM is correctly installed and verified, you have a powerful, centralised system for managing all your tracking codes — without touching theme files every time you need to add or update a tag.