To add Google Tag Manager to WordPress, paste GTM’s two snippets into your site (one high in the <head>, one right after the opening <body> tag) or let a plugin such as Site Kit or GTM4WP place them for you. Then set up consent mode, check every tag in Tag Assistant preview, and publish. GTM itself is light. The tags you put inside it are what slow a site down, so keep the container lean. Below I cover the manual method, the plugin options, consent, speed and testing.

Most WordPress sites I’m asked to look at already have tracking. The problem is that it’s scattered: a GA4 code in the theme header, a Meta pixel pasted into a page builder, a Google Ads tag added by a plugin, and an old Universal Analytics snippet nobody removed. Some events fire twice, some never fire, and nobody knows which code does what.

A clean Google Tag Manager WordPress setup fixes that. You install one container, and every tracking tag lives inside it, where you can see it, test it and remove it without touching theme files.

This guide is the Google Tag Manager WordPress process I follow on client sites. It’s written for site owners and marketers who are comfortable in the WordPress dashboard, not only for developers.

What is Google Tag Manager, and why use it on WordPress?

Google Tag Manager (GTM) is a free tool from Google that loads your tracking and marketing tags from one container. Instead of pasting GA4, Google Ads, Meta, LinkedIn and Hotjar codes into your theme one by one, you add the GTM container once and manage the rest from the GTM interface.

For a Google Tag Manager WordPress install, that brings a few real benefits:

  • No more theme edits for every new tag. A theme update or a theme switch won’t wipe out your tracking.
  • One place to see everything. You can open the container and know exactly which tags run, and when.
  • Testing before publishing. Preview mode shows what fires on each page before real visitors see any change.
  • Version history. Every publish is saved, so a broken change can be rolled back in a minute.
  • Consent control. Tags can respect the visitor’s cookie choices from one central setup.

Who it’s NOT for: if your site only needs GA4 and you’ll never add another tag, a Google Tag Manager WordPress setup is optional. Site Kit or a single GA4 tag is enough. Google Tag Manager on WordPress pays off once you have two or more tags, conversion tracking or a consent banner to respect.

Before you start: get your container ID

Create a free account at Google Tag Manager, add a container for your website, and choose “Web” as the platform. GTM then shows you two code snippets and a container ID that looks like GTM-XXXXXXX. Keep that tab open, because every Google Tag Manager WordPress method below needs that ID.

Two quick checks before any Google Tag Manager WordPress install:

  1. Look for existing tracking. View the page source and search for gtag(, googletagmanager.com and fbq(. If GA4 is already hard-coded, plan to remove it once GTM takes over, or you’ll count every visit twice.
  2. Check for a second container. Some themes and marketing plugins add their own GTM container. Two containers can work together, but most of the time one of them is a leftover.

Method 1: add Google Tag Manager to WordPress manually

Google’s own Tag Manager setup guide is clear about placement: paste the first snippet as high in the <head> as possible, and the second snippet (the <noscript> iframe) immediately after the opening <body> tag. The first one does the real work. The second only matters for visitors with JavaScript turned off.

Don’t paste them into header.php directly. A theme update will overwrite your edit. Use a child theme’s functions.php or a code snippets plugin instead. This is the code I use for a manual Google Tag Manager WordPress install:

add_action( 'wp_head', function () { ?>
<!-- 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-XXXXXXX');</script>
<!-- End Google Tag Manager -->
<?php }, 1 );

add_action( 'wp_body_open', function () { ?>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<?php } );

Replace GTM-XXXXXXX with your container ID, or better, copy the exact snippets from your GTM account. The priority 1 on wp_head puts the script near the top of the head, as Google asks.

The body snippet uses the wp_body_open hook, added in WordPress 5.2. Most modern themes support it. If yours doesn’t, the noscript part simply won’t print, and GTM still works for every visitor with JavaScript, which is nearly all of them.

What about block themes and the Site Editor?

Block themes don’t have a header.php you can safely edit, so the hook method above is the right way. Don’t add the GTM script inside a Custom HTML block in the header template part. It loads later than it should and is easy to delete by accident when someone edits the header.

Method 2: use a Google Tag Manager WordPress plugin

If you’d rather not touch code, a Google Tag Manager WordPress plugin can place the container for you. These are the two I trust most, and both are free.

Site Kit by Google

Site Kit is Google’s official WordPress plugin, with more than 5 million active installs. Its Tag Manager module connects your Google account, lets you pick a container and places the code with no code editing. It also connects Search Console, Analytics and AdSense in the same plugin.

Site Kit is the simplest choice for a basic Google Tag Manager WordPress setup. The trade-off is that it only places the container. It doesn’t add WordPress data like post category, author or user role to the data layer.

GTM4WP

GTM4WP by Thomas Geiger is the plugin I reach for when tracking needs to go deeper. Its readme describes what it adds on top of placing the container:

  • Page and post data pushed to the data layer: post type, categories, tags, author, logged-in status and user role.
  • GA4 ecommerce events for WooCommerce, including the block-based cart and checkout.
  • Form events for Contact Form 7, plus media player and scroll tracking.
  • Google Consent Mode v2 default settings, and integrations with several consent plugins.
  • Options for placing the noscript snippet, including a footer fallback for themes without wp_body_open.

That makes GTM4WP the stronger Google Tag Manager WordPress plugin for WooCommerce stores and for anyone who wants triggers based on WordPress content. It has more settings to understand, so turn on only what you’ll use.

Google Tag Manager WordPress install methods compared
Three ways to place the GTM container on a WordPress site.

Manual code vs plugin: which should you choose?

MethodBest forProsCons
Manual (functions.php or snippets plugin)Developers, lean sitesNo extra plugin, full controlNeeds care on theme changes; no WordPress data layer
Site KitMost small business sitesOfficial, simple, also connects Search Console and GA4Places the container only
GTM4WPWooCommerce stores, advanced trackingRich data layer, ecommerce events, consent defaultsMore settings to configure correctly

My rule of thumb: a brochure site or blog gets Site Kit or the manual method. A WooCommerce store, or any site where marketing needs reliable conversion data, gets GTM4WP. Whichever Google Tag Manager WordPress method you pick, use only one. Two methods placing the same container is one of the most common causes of doubled pageviews I see.

Does Google Tag Manager slow down WordPress?

The container itself loads asynchronously, as you can see from j.async=true in Google’s snippet, so it doesn’t block the page from rendering. On its own, a Google Tag Manager WordPress install adds one script request and is rarely the problem.

The problem is what goes inside it. Every tag you add is more JavaScript the browser has to download and run: chat widgets, heatmap tools, ad pixels, A/B testing scripts. Heavy tags hurt Interaction to Next Paint (INP) most, because the browser is busy running scripts while the visitor tries to tap or type. If you’re not sure what good numbers look like, my guide to Core Web Vitals thresholds explains them.

This is how I keep a Google Tag Manager WordPress container fast:

  • Audit before adding. Every tag needs an owner and a reason. If nobody can say why a tag is there, pause it.
  • Use built-in tag types instead of Custom HTML where possible. They’re usually lighter and easier to maintain.
  • Fire tags only where needed. A thank-you page conversion tag doesn’t need to load on every blog post.
  • Delay non-essential tags. Heatmaps and chat widgets can fire on Window Loaded or after a short timer instead of on page load.
  • Don’t load GA4 twice. Remove hard-coded GA4 once it runs through GTM.
  • Be careful with caching and delay plugins. Some speed plugins delay all JavaScript until user interaction, which can break or undercount tracking. Exclude googletagmanager.com if events go missing.

If your site is slow for other reasons too, my WordPress PageSpeed checklist covers the bigger wins, such as images, hosting and render-blocking CSS.

Keep a Google Tag Manager WordPress container fast
Five habits that keep GTM from slowing your WordPress site.

If you have visitors from the EU, UK or other regions with consent laws, or you run Google Ads, consent mode belongs in your setup. Google’s consent mode overview defines four main consent types:

Consent typeWhat it controls
ad_storageCookies or identifiers related to advertising
analytics_storageCookies related to analytics, such as visit duration
ad_user_dataSending user data to Google for advertising
ad_personalizationPersonalized advertising

Google describes two ways to implement it. Basic consent mode blocks Google tags until the visitor makes a choice on the banner. Advanced consent mode loads the tags with consent denied by default, and they send measurements without cookies until the visitor agrees. Advanced gives you more modeled data. Basic is simpler and stricter.

For Google Tag Manager WordPress sites, the practical setup is a consent plugin plus GTM:

  1. Install a consent management plugin (CookieYes, Complianz, Cookiebot and similar tools have consent mode support).
  2. Set default consent states before GTM loads. Many consent plugins do this for you. GTM4WP can also send the default command itself.
  3. In GTM, check each tag’s consent settings so non-Google tags, such as the Meta pixel, only fire after the right consent is granted.
  4. Test with the banner in both states: accepted and rejected.

If you use Site Kit, its consent mode setting needs the WP Consent API plugin plus a consent management plugin to work. By default it applies to visitors from the EEA, Switzerland and the UK. I’m not a lawyer, and which laws apply depends on where your visitors are, so check that part with someone qualified.

How to test your setup with Tag Assistant

Never publish a Google Tag Manager WordPress change without previewing it. Google’s guide to getting started with Tag Manager covers preview mode. In short:

  1. In your GTM workspace, click Preview. Tag Assistant opens in a new tab.
  2. Enter your site’s URL and click Connect. Your site opens with a “Connected” badge.
  3. Go back to the Tag Assistant tab and click Continue.
  4. Browse the site: visit pages, submit a test form, add a product to the cart. Tag Assistant shows which Google Tag Manager WordPress tags fired, which didn’t, and the trigger behind each one.
  5. When everything looks right, go back to GTM, click Submit, name the version clearly and publish.

Then confirm the data actually arrives: open GA4’s DebugView or Realtime report and check your test events. On a Google Tag Manager WordPress site, also test while logged out. Some setups exclude logged-in users or administrators, and many site owners panic when their own visits don’t show up.

Common problems I find when testing

  • Container not found: a caching plugin is still serving old pages. Clear every cache layer, including the host and CDN.
  • Tags fire twice: GTM is placed twice, or GA4 is also hard-coded in the theme.
  • Form conversions never fire: the form submits with AJAX, so a page view trigger on a thank-you URL never runs. Use the form plugin’s own event, or a GTM4WP form event.
  • Preview won’t connect: an ad blocker or strict browser privacy setting is blocking Tag Assistant. Try a clean browser profile.

A clean Google Tag Manager WordPress setup, step by step

Putting it all together, this is the Google Tag Manager WordPress order I work in on a new site:

  1. Audit existing tracking and list every tag the business actually needs.
  2. Create the GTM container and note the container ID.
  3. Place the container with one method only: Site Kit, GTM4WP or a manual hook.
  4. Set up the consent plugin and default consent states.
  5. Add the GA4 configuration tag, then conversion events such as form submits, calls and purchases.
  6. Add other platforms (Google Ads, Meta, LinkedIn) with consent checks.
  7. Preview everything in Tag Assistant, on desktop and mobile.
  8. Publish with a clear version name, and remove any old hard-coded tags.
  9. Check GA4 data after 24 to 48 hours, and run a speed test to confirm nothing got slower.

Done this way, a Google Tag Manager WordPress install is something you set up once and then maintain with small, tested changes. A broken Google Tag Manager WordPress setup is also a common gap I find during technical audits. If you’d like to see what an audit covers, here’s my SEO audit report breakdown.

Google Tag Manager WordPress mistakes to avoid

Most Google Tag Manager WordPress problems I fix come from a short list of habits:

  • Pasting the snippet in a page builder’s header widget or a Custom HTML block. It may load late, or vanish when someone edits the header.
  • Using two methods at once, such as Site Kit and a manual snippet, so everything is counted twice.
  • Giving everyone Publish access. In GTM, most people only need Edit or Read. Fewer publishers means fewer surprises.
  • Never cleaning up. Tags for old campaigns and expired tools stay active for years, adding weight to every page.
  • Skipping consent because the site is “only in the US”. Google Ads and visitors from other regions can still make it relevant.
  • Not naming things. “Tag 14” tells nobody anything. Use names like “GA4 – Event – Contact form submit”.

Frequently asked questions

How do I add Google Tag Manager to WordPress without a plugin?

Add the GTM head snippet with the wp_head hook and the noscript snippet with the wp_body_open hook, in a child theme’s functions.php or a code snippets plugin. Don’t edit header.php directly, because theme updates overwrite it.

What is the best Google Tag Manager WordPress plugin?

For a simple setup, Site Kit by Google places the container and connects your Google accounts. For WooCommerce stores and advanced tracking, GTM4WP is stronger, because it adds WordPress and ecommerce data to the data layer.

Does GTM slow down a WordPress site?

A Google Tag Manager WordPress container loads asynchronously and is light on its own. The tags inside it, such as chat widgets, heatmaps and ad pixels, are what add weight. Keep the container lean and fire tags only where they’re needed.

Do I still need the noscript part of the GTM code?

It only helps visitors who have JavaScript turned off, which is a very small group. Google recommends adding it right after the opening body tag. If your theme doesn’t support wp_body_open, GTM still works without it.

Do I need consent mode for GTM in WordPress?

If you have visitors from regions with consent laws, such as the EU or UK, or you use Google Ads, you should set it up. A consent plugin sets the default consent states, and the tags in your Google Tag Manager WordPress container respect them.

How do I know if Google Tag Manager is working on my WordPress site?

Use GTM’s Preview button to open Tag Assistant for your Google Tag Manager WordPress container, connect to your site and check which tags fire on each page. Then confirm the events arrive in GA4’s DebugView or Realtime report.

Want GTM set up and tested for you?

I do Google Tag Manager WordPress setups with GA4, with form and button conversions tracked and every tag tested in preview mode before publishing. Tracking setup is a fixed $49 on my technical SEO service, and slow sites can get help through my WordPress speed optimization service. Send me your site URL and tell me what you want to track.