Skip to main content

GA4 + GTM Setup for WordPress: The Complete 2026 Guide

## Why Most WordPress GA4 Setups Are Broken In my work auditing websites, I find the same tracking problems repeatedly: GA4 installed three times (once via plugin, once in functions.php, once in the theme), conversion events that never fire, form submissions that don't track, and goal completions showing as 0 even when enquiries are coming through. Reliable analytics are the foundation of every informed digital marketing decision. If your data is wrong, your decisions are wrong. This guide walks through the correct way to set up GA4 via Google Tag Manager on a WordPress site in 2026. ## Why GTM + GA4 (Not Direct Integration) Many WordPress plugins offer "one-click GA4 integration." They work, but using Google Tag Manager (GTM) as an intermediary is significantly better: 1. **No code changes needed** for future tracking updates — add/modify tags in GTM without touching your theme 2. **One container manages everything** — GA4, Meta Pixel, LinkedIn Insight Tag, conversion tags, all in one place 3. **Preview and debug** before publishing — test every tag before it goes live 4. **Consent mode integration** — GTM handles consent mode natively for GDPR compliance 5. **Version history** — every GTM change is versioned; roll back any time ## Step 1: Create Your GTM Container 1. Go to [tagmanager.google.com](https://tagmanager.google.com) 2. Create Account → Add Container 3. Container name: `helloamanuel.co.uk` (use your domain) 4. Target platform: **Web** 5. Note your **Container ID** (format: `GTM-XXXXXXX`) **Installing GTM on WordPress:** The cleanest method: add the GTM snippets directly to your theme's `functions.php` or `header.php`: ```php // GTM head snippet (place immediately after opening tag) function add_gtm_head() { $gtm_id = 'GTM-XXXXXXX'; // Replace with your Container ID if ( empty( $gtm_id ) ) return; echo "\n"; echo "\n"; echo "\n"; } add_action('wp_head', 'add_gtm_head', 1); // GTM body snippet (place immediately after opening tag) function add_gtm_body() { $gtm_id = 'GTM-XXXXXXX'; // Same Container ID if ( empty( $gtm_id ) ) return; echo "\n"; echo "\n"; echo "\n"; } add_action('wp_body_open', 'add_gtm_body', 1); ``` Alternatively, use the `.env` + `config/services.php` approach for Statamic-based sites (as implemented on this site). ## Step 2: Create Your GA4 Property 1. Go to [analytics.google.com](https://analytics.google.com) 2. Create a new property → choose **Google Analytics 4** 3. Set timezone to **United Kingdom (GMT/BST)** 4. Set currency to **British Pound (GBP)** 5. Complete the Business Information fields 6. Note your **Measurement ID** (format: `G-XXXXXXXXXX`) **In GA4, configure data retention:** - Admin → Data Settings → Data Retention → Set to **14 months** (maximum available without going through BigQuery) ## Step 3: Add GA4 Tag in GTM 1. In GTM: Tags → New → Tag Configuration → Google Tag (or GA4 Configuration) 2. Tag type: **Google Tag** 3. Tag ID: your `G-XXXXXXXXXX` Measurement ID 4. Trigger: **All Pages** (Page View trigger) 5. Name: `GA4 - Configuration` 6. Save **Configure enhanced measurement:** Back in GA4 → Admin → Data Streams → your stream → Enhanced Measurement. Enable: - Page views (automatically enabled) - Scrolls (90% scroll depth) - Outbound clicks - File downloads - Video engagement (if using YouTube embeds) - Form interactions (**important** — enable this for basic form tracking) ## Step 4: Set Up Conversion Events This is where most setups fail. "Enhanced measurement" form tracking is unreliable — it fires on any click of a submit button, regardless of whether the form submitted successfully. For reliable contact form conversion tracking, use one of these approaches: ### Approach A: Thank You Page / Redirect If your form redirects to `/contact/?success=1` after submission: **In GTM, create a trigger:** - Trigger type: Page View - This trigger fires on: Some Page Views - Condition: Page URL → contains → `success=1` - Name: `Trigger - Contact Form Thank You` **Create a tag:** - Tag type: Google Analytics: GA4 Event - Configuration Tag: your GA4 Configuration tag - Event Name: `generate_lead` (this is a GA4 recommended event) - Trigger: `Trigger - Contact Form Thank You` **In GA4:** - Admin → Events → find `generate_lead` → toggle "Mark as conversion" ### Approach B: JavaScript Event (for AJAX forms) If your form doesn't redirect, push a custom event via JavaScript when the form submits successfully: ```javascript // In your theme's JS, after successful form submission: window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'form_submit', 'form_type': 'contact', 'page_location': window.location.href }); ``` In GTM, create a Custom Event trigger listening for `form_submit`, then a GA4 Event tag. ## Step 5: Track Phone Number Clicks Phone call intent is a critical conversion event for service businesses. **In GTM, create a trigger:** - Trigger type: Click - Just Links - This trigger fires on: Some Link Clicks - Condition: Click URL → starts with → `tel:` - Name: `Trigger - Phone Click` **Create a tag:** - Tag type: GA4 Event - Event Name: `click` (or custom: `phone_click`) - Parameters: `link_url` → `{{Click URL}}` - Trigger: `Trigger - Phone Click` Repeat this pattern for WhatsApp links (`wa.me`), email links (`mailto:`), and any other key micro-conversions. ## Step 6: Consent Mode (UK GDPR Compliance) With UK GDPR, you should implement consent mode to ensure GA4 respects cookie preferences. **Basic consent mode setup in GTM:** Create a new tag: - Tag type: **Consent Initialization - All Pages** (custom HTML) ```html ``` Then, when a user accepts cookies, fire an update: ```javascript gtag('consent', 'update', { 'analytics_storage': 'granted' }); ``` Trigger this consent update from your cookie banner's accept action (as implemented in `app.js` for this site, which pushes to `dataLayer`). ## Step 7: Common Mistakes to Avoid **Mistake 1: Duplicate tracking** Check you haven't installed GA4 via a plugin AND GTM. Use the Tag Assistant Chrome extension to verify — you should see exactly one `gtag.js` or GTM firing per page. **Mistake 2: Not excluding internal traffic** Add your office IP addresses to GA4 exclusion filters: Admin → Data Filters → Create Filter → Internal Traffic. Otherwise your own visits inflate your data. **Mistake 3: Wrong event names** GA4 has a set of [recommended events](https://developers.google.com/analytics/devguides/collection/ga4/reference/events). Use these where possible (`generate_lead`, `purchase`, `sign_up`) rather than custom names — they integrate with Google Ads and other tools automatically. **Mistake 4: Not testing in Preview mode** Always click "Preview" in GTM before publishing. Walk through every conversion action and verify the tags fire correctly in the GTM preview panel. Only then publish. **Mistake 5: Forgetting mobile** Test conversion tracking on a real mobile device, not just desktop. Form interactions and click events behave differently on touch screens. ## Verifying Your Setup After publishing in GTM, verify with these tools: 1. **GTM Preview mode** — shows every tag firing and why 2. **GA4 DebugView** — Admin → DebugView (enable via GTM debug mode) 3. **Google Tag Assistant** — Chrome extension for real-time tag verification 4. **GA4 Realtime report** — watch events fire as you test ## Getting Professional Help If you've read this and it feels overwhelming — that's completely normal. Proper GA4 configuration is surprisingly complex for what should be straightforward tracking. I offer GA4 + GTM setup as a standalone service (typically £350-500 depending on complexity) and as part of my managed SEO and paid advertising packages. [Book a free consultation →](/contact) to discuss your analytics setup and what's potentially costing you in lost insights. --- *Amanuel Wasihun is a Technical SEO Specialist and WordPress Architect based in Liverpool. He provides GA4, GTM, and full analytics configuration for UK businesses as part of his digital services offering.*
Back to all posts