What GTM4WP does on your site
GTM4WP adds the Google Tag Manager container code to your pages: the main script in the <head> section and the <noscript> part wherever you choose. It handles several containers, each with its own environment parameters, plus a custom domain for a server-side container. The plugin creates no tags itself: your Google Analytics 4, Google Ads and other tags are set up in the Google Tag Manager interface.
Its real job is filling the data layer (dataLayer) with what WordPress knows: post type, categories, author, site search, and the logged-in user’s status and role. It adds events for about a dozen media players (YouTube, Vimeo, HTML5, Wistia...), Contact Form 7 submissions, sign-ups and logins, and the full WooCommerce purchase funnel in the GA4 e-commerce format, including the Cart and Checkout blocks.
Thomas Geiger has developed the plugin since 2013. It is completely free (GPLv3 license); the only paid offering is tracking implementation and audits, quoted per project by JabJab Online Marketing, the agency where he is COO. Version 2.0 is a full rewrite that requires PHP 8.0 and WordPress 6.3.
Which sites GTM4WP is a good fit for
GTM4WP pays off when someone, in house or at an agency, already manages tags in Google Tag Manager:
- WooCommerce stores: the
view_item,add_to_cart,begin_checkoutandpurchaseevents arrive ready for GA4 and Google Ads conversions, with no code. - Content sites that measure engagement: video plays, form submissions, estimated reading time and categories help group pages in GA4.
- Agencies rolling out the same tracking on many sites: settings export and import in JSON, and a container ID you can lock in
wp-config.php.
It is the wrong pick if you only want stats in your dashboard without ever opening Google Tag Manager: Site Kit by Google installs the Google tag and shows reports inside WordPress, with no data layer to configure.
GTM4WP strengths and limitations
Strengths
- Everything is free. GA4 e-commerce, media events, consent and integrations are not locked behind any paid plan.
- Complete WooCommerce e-commerce. Block-based cart and checkout, enhanced conversions data for Google Ads, and recovery of missed purchases.
- Useful safeguards. Tag type restrictions, a production-only container and a data layer that stays safe behind a page cache.
- Consent built in. Google Consent Mode "default" command and bridges to Cookiebot, CookieYes, Axeptio and WebToffee.
Limitations
- Google Tag Manager required. The plugin only pushes data: without tags and triggers built in GTM, nothing gets measured.
- Version 2.0 breaks some habits. Scroll tracking, weather and geo data are gone, and the
pageTitleandsiteSearchTermformats changed in 2.0.6. - Cache-safe mode still experimental. It is off by default, while a page cache can serve a logged-in user’s email address to other visitors.
- No refund tracking. The WooCommerce e-commerce integration supports neither refunds nor promotions.
The GTM4WP settings we recommend
Everything lives under Settings > Google Tag Manager. Enter your container ID (GTM-XXXXXX) first, then:
| Setting | Recommended value | Why |
|---|---|---|
| Container code placement Settings > Google Tag Manager > Google Tag Manager container > General | "Automatically after the opening body tag" if your theme supports wp_body_open | The placement Google recommends; otherwise keep the footer (the default). |
| Load GTM container as early as possible Same screen > Advanced | Off (default) | The developer warns it can break custom HTML tags that use jQuery. |
| Only output the container on production environments Same screen > Advanced | On, if your test copies set WP_ENVIRONMENT_TYPE | A staging copy stops sending data to your live container; the data layer stays active. |
| User roles to exclude Same screen > Advanced | Administrator, plus Editor if needed | Your own visits no longer skew your stats: the container does not load for these roles. |
| Logged in user email and Visitor IP Settings > Google Tag Manager > Page variables > Visitor data | Off (default) | Both are personal data; the plugin itself notes that the IP address requires explicit consent. |
| Submitted field values in the data layer Settings > Google Tag Manager > Contact Form 7 | "Field names only (no values)" | By default, what visitors type (email, message) goes into the data layer. |
| Enable cache-safe data layer Settings > Google Tag Manager > Cache-safe data layer | On, if you use a page cache and push visitor data | A cached page no longer hands one visitor’s data to the next; your tags then listen for gtm4wp.visitorData. |
| Restriction mode Settings > Google Tag Manager > Tag restrictions | "Blocklist selected entities" with Custom HTML Tag, Custom JavaScript Variable and "Sandboxed custom template scripts", if your container does not use them | If the Google account that runs the container is compromised, these tag types can no longer run scripts on your site. |
- View a page’s source: your container ID should appear only once; otherwise a theme or another plugin is adding it too.
- Run Google Tag Manager’s Preview mode in a private window, since an excluded role does not load the container.
- Type
dataLayerin the browser console: no email address or form value should show up. - On a store, place a test order and check in Preview that exactly one
purchaseevent is sent.
GTM4WP security: three patched XSS flaws and a risk on Google’s side
Every published GTM4WP vulnerability is an XSS flaw tied to data written back into the data layer:
- CVE-2026-16597, fixed in 1.22.4: unauthenticated stored XSS through the billing fields of a WooCommerce guest order, when the "Order data in data layer" option is on (CVSS 7.2).
- CVE-2022-1707, fixed in 1.15.1: reflected XSS through the site search term, when search data was pushed into the data layer (CVSS 6.1).
- CVE-2022-1961, fixed in 1.15.2: stored XSS by an administrator through a scroll tracking setting, on sites where
unfiltered_htmlis disabled (CVSS 5.5).
The bigger risk sits elsewhere: Google Tag Manager can run any script on every page, so protect the Google account behind it with two-factor authentication and use the tag restrictions above. Turn on auto-updates for the plugin too (see our guide to plugin auto-updates). GTM4WP stamps your pages with "Google Tag Manager for WordPress by gtm4wp.com" HTML comments that WP Feint Pro removes; Pro also renames the plugin folder, and hiding these traces is no substitute for updating.
What WP Feint hides for GTM4WP
Pro Handled by WP Feint Pro only
The free version does not know the traces specific to GTM4WP: without Pro, only generator tags are removed, as for any plugin.
Free version
Handled by WP Feint Pro only
With Pro
- signed HTML comments
- folder name
- tag IDs
Still visible
- JavaScript variables
gtm4wp_*
These traces stay because the plugin needs them to work (scripts, styles, cookies) or because they come from the server.
GTM4WP frequently asked questions
GTM4WP or Site Kit: which one should I pick?
Site Kit is enough to install the Google tag and read your reports inside WordPress. GTM4WP is for people who manage their tags in Google Tag Manager and want WordPress and WooCommerce data in the data layer.
Does GTM4WP make my tracking GDPR compliant?
Not on its own: it sends the Google Consent Mode defaults and talks to several consent tools, but your banner and your tag setup decide what gets collected. Keep any personal data you do not use switched off (see GDPR and WordPress security).
Should I upgrade from 1.x to version 2.0?
Test on a copy first: 2.0 requires PHP 8.0 and WordPress 6.3, and drops scroll tracking, which you replace with Google Tag Manager’s built-in Scroll Depth trigger. Filter names, constants and options from 1.x are kept.
Why are some PayPal purchases missing in GA4?
The purchase event fires on the order received page, and some payment methods never send the customer back there. The developer recommends turning on auto-return in the gateway, and the "Reliable purchase tracking" option sends the missed purchase on the next page the customer views.