What is the best way to install GA4 on WordPress?
Three installation methods for GA4 on WordPress: (1) Via GTM (Google Tag Manager plugin + GA4 configuration in GTM — recommended for sites needing Consent Mode V2 and custom events), (2) Via a dedicated GA4 plugin (Site Kit by Google, MonsterInsights — quick setup but limited custom event flexibility), (3) Manual gtag.js in theme functions.php (simple but requires developer access for all changes). The recommended method for most WordPress sites: GTM via the official Google Tag Manager plugin. GTM provides the flexibility to add Consent Mode V2, WooCommerce purchase events, and future custom events without WordPress theme edits.
Method 1 — GTM on WordPress (recommended)
Install the Google Tag Manager for WordPress plugin (by Thomas Geiger, ~2M installs) or the official Google Site Kit plugin's GTM integration.
Configuration:
- WordPress Admin → Plugins → Add New → search "Google Tag Manager for WordPress" → install and activate
- Settings → Google Tag Manager → enter your GTM container ID (GTM-XXXXXX)
- Enable "Track users in GTM" if using User-ID integration
- In GTM, create your GA4 Configuration tag and GA4 event tags as normal
Consent Mode V2 with Complianz:
Complianz (WordPress plugin) has a dedicated GTM integration. Install Complianz, configure your cookie consent settings, and enable the GTM integration. Complianz automatically handles the Consent Mode V2 default and update states via GTM's Consent Initialization trigger.
Consent Mode V2 with Cookiebot:
Install the Cookiebot plugin for WordPress. In GTM, install the Cookiebot Community Template from the Template Gallery. The template handles all Consent Mode V2 parameters automatically.
Method 2 — Dedicated GA4 plugin
Site Kit by Google
Pros: Official Google plugin, direct GA4 connection without GTM, shows basic GA4 data in WordPress dashboard.
Cons: Limited custom event support, no Consent Mode V2 (you'd need a separate CMP plugin), less flexible than GTM for advanced tracking.
Best for: Simple informational sites with basic traffic monitoring needs and no paid advertising.
MonsterInsights
Pros: User-friendly, WooCommerce e-commerce tracking built in, automatic form tracking.
Want to see which hidden implementation gaps are affecting your GA4 data quality?
Cons: Paid (from ~$99/year), Consent Mode V2 support limited in lower tiers, some events require higher-tier plans.
Best for: Non-technical WordPress admins who need e-commerce tracking without custom GTM work.
WooCommerce e-commerce tracking
For accurate WooCommerce e-commerce tracking, the recommended approach is GTM with a dataLayer integration.
Option A — Plugin-based dataLayer push:
Install "WooCommerce Google Tag Manager" plugin (or similar) that pushes WooCommerce events to the dataLayer in GA4-compatible format.
Verify by checking window.dataLayer in browser console after adding a product to cart — should show:
Option B — Custom functions.php dataLayer push:
Add custom PHP to your theme's functions.php to push WooCommerce purchase data to the dataLayer on the thank-you page:
WordPress caching problems that break GA4
Problem 1 — Caching the thank-you page If your WordPress caching plugin (WP Rocket, W3 Total Cache, LiteSpeed Cache) caches the WooCommerce thank-you/order-received page, the purchase event fires for every user who loads the cached page — even returning visitors who didn't just complete an order.
Fix: Exclude the thank-you page from caching:
- WP Rocket: Settings → Cache → Never Cache the Following Pages → add
/checkout/order-received/ - W3 Total Cache: Performance → Page Cache → Never cache the following pages → add the order URL pattern
Problem 2 — Minification breaking the GTM snippet Aggressive JavaScript minification can break the GTM container snippet or the dataLayer push code.
Fix: Exclude GTM-related scripts from minification in your caching plugin settings.
Problem 3 — Lazy-loading the GTM script Some performance optimisation plugins move scripts to the footer or apply lazy-loading. The GTM snippet must load synchronously in <head> (for the <noscript> part in <body> too). Lazy-loading breaks Consent Mode V2 timing.
Fix: Mark GTM scripts as excluded from lazy-loading/deferral in your performance plugin.
FAQ: GA4 for WordPress: The Complete Setup Guide
What should a team validate first when ga4 for wordpress: the complete setup guide appears?
How do I know whether the fix actually worked?
When should this become a full GA4 audit instead of a quick fix?
Related guides for GA4 for WordPress: The Complete Setup Guide
Server-Side GTM Hosting Cost Benchmarks: Cloud Run vs Stape vs Self-Hosted (2026)
Server-side GTM hosting falls into three pricing models in 2026: Google Cloud Run (variable, starts at ~€120/month for 3 minimal servers, scales to €240–€300 for higher traffic, plus optional logging fees), managed providers like Stape (fixed monthly: €20/month for 500k requests…
Server-Side GTM vs Client-Side GTM: A Decision Matrix (2026)
Move to server-side GTM if you (1) need Conversions API integrations with Meta, Google Ads, TikTok, or LinkedIn for offline-conversion match quality (the strongest single justification — typical 9–24% conversion lift)…
Run a GA4 audit before ga4 for wordpress: the complete setup guide spreads into reporting decisions
Use GA4 Audits to surface implementation gaps, broken signals, and the next fixes to prioritize before the issue becomes harder to trust or explain.