Install on WordPress
Two install paths. The plugin route is recommended for non-developers; thefunctions.php route is recommended for developers running custom themes.
Option A — Insert Headers and Footers plugin (recommended)
- WordPress Admin → Plugins → Add New
- Search for "Insert Headers and Footers" by WPCode (very common, has 1M+ active installs)
- Install → Activate
- Settings → Insert Headers and Footers
- In Scripts in Header, paste the GTM head snippet (from the wizard's WordPress Install tab)
- In Scripts in Body (or Footer if your theme doesn't support body), paste the GTM noscript snippet
- Save changes
Equivalent alternatives: WPCode Lite, Header Footer Code Manager, or any plugin that lets you inject raw HTML into <head> + after <body>.
Option B — functions.php (developers)
Best with a child theme so theme updates don't wipe your changes. Hooks into the standard wp_head and wp_body_open actions.
Copy the PHP snippet from the wizard's WordPress Install tab → Option B card, and paste it into your child theme's functions.php. It registers both action callbacks. Save the file and the GTM snippets will appear on every page.
Step 3 — Verify
- Visit your site in an incognito window
- View the page source (Cmd+Option+U)
- Search for
googletagmanager.com/gtm.js— should be in<head> - Search for
googletagmanager.com/ns.html— should be in a<noscript>tag right after<body>
Pre-built event templates for WordPress
wordpress:ga4:form_submit— Contact Form 7, WPForms, Gravity Formswordpress:ga4:comment_submit— blog comment formswordpress:ga4:search— WordPress searchwordpress:ga4:loginwordpress:ga4:signup
WooCommerce on top of WordPress
If your site is a WordPress + WooCommerce store, install GTM as above and then follow the WooCommerce guide for the GTM4WP plugin which auto-pushes e-commerce events.
Common gotchas
- Page caching — clear your WP cache (W3 Total Cache, WP Rocket, etc.) after installing the snippet, otherwise old pages still serve without it.
- CSP headers — if you use a Content Security Policy plugin, you may need to allow
googletagmanager.comand your Measurement ID domain. - Multiple GTM containers — don't install TagEasy alongside another GTM plugin. They'll inject conflicting snippets and double-fire events.