TopSyde
Get your free site audit30-Day Free Trial

WordPress Google Analytics Setup: Complete GA4 Guide

Step-by-step GA4 setup for WordPress — including goals, ecommerce tracking, plugin options, and the configuration mistakes that silently break your data.

Rachel Nguyen

Rachel Nguyen

Senior WordPress Engineer

··12 min read

Last updated: June 28, 2026

WordPress dashboard open alongside Google Analytics 4 property setup screen showing data stream configuration

Google Analytics 4 (GA4) is Google's current measurement platform, replacing Universal Analytics (which sunset in July 2023). Properly implementing GA4 on WordPress means deploying the gtag.js snippet or using the Google Site Kit plugin, configuring a data stream, enabling enhanced measurement, and validating that events fire correctly — before you trust a single number in your reports.

What Is GA4 and How Is It Different from Universal Analytics?

GA4 is an event-based measurement model. Every interaction — page view, scroll, click, form submission — is recorded as an event with parameters, rather than as a hit against a session/pageview hierarchy. Universal Analytics used a session-scoped model with predefined hit types (pageview, event, transaction). GA4 unifies everything under a single event schema, which gives you more flexibility but also more surface area for misconfiguration.

The practical implication for WordPress developers: you cannot migrate a UA property to GA4. You create a new GA4 property, connect a web data stream, and start fresh. Historical UA data is accessible in your old property (read-only) until Google removes it, but it does not port to GA4 reports.

According to W3Techs, Google Analytics is used by 55.4% of all websites tracked in their dataset (2024), making correct implementation a baseline competency for any WordPress professional.

How to Create a GA4 Property and Web Data Stream

In Google Analytics:

  1. Go to Admin → Create Property
  2. Enter your property name, reporting time zone, and currency
  3. Under Data collection and modification, select Web
  4. Enter your WordPress site URL and stream name
  5. Copy the Measurement ID (format: G-XXXXXXXXXX)

Keep this tab open — you'll need the Measurement ID for whichever deployment method you choose.

Enhanced Measurement is enabled by default on new data streams. It auto-tracks:

  • Page views
  • Scrolls (90% threshold)
  • Outbound link clicks
  • Site search (if ?s= or your custom search param is configured)
  • Video engagement (YouTube embeds only, by default)
  • File downloads

Verify these settings under Data Streams → [your stream] → Enhanced Measurement. They are useful but can create duplicate events if you also fire these manually via GTM or a plugin.

How to Add GA4 to WordPress: Three Methods Compared

MethodTechnical OverheadCustomizationPerformance ImpactBest For
Google Site Kit pluginLowLowModerate (extra JS)Non-technical site owners
MonsterInsights pluginLow–MediumMediumModerateMarketers who want UI-based goals
Google Tag ManagerMediumHighLow (async, single request)Developers, multi-tag setups
Manual wp_head snippetLowLowLowestSimple sites, developers who want full control

Method 1: Google Site Kit

Install the Site Kit by Google plugin from the WordPress repository. On activation, it walks you through a Google OAuth flow, detects your GA4 property, and injects the gtag.js snippet via its own mechanism. It also surfaces a lightweight analytics dashboard inside wp-admin.

Caveat: Site Kit injects analytics on every page load via PHP. It does not use GTM, so adding additional tracking tags later requires either a separate GTM container or additional plugins. For simple informational sites, this is fine. For ecommerce or anything requiring custom event tracking, the coupling gets painful quickly.

Method 2: MonsterInsights

MonsterInsights connects to GA4 via OAuth and injects the GA4 snippet. The Pro tier adds ecommerce tracking for WooCommerce, form conversion tracking, and custom dimensions — all configurable through a WordPress UI rather than GTM.

For WooCommerce stores specifically, MonsterInsights Pro is one of the fastest paths to ecommerce event tracking without writing custom JavaScript. That said, be aware it adds ~40–60KB of additional JavaScript to your frontend, which matters if you're already working to optimize Core Web Vitals. (See our guide on how WordPress site speed directly impacts revenue for why that payload cost is real.)

GTM is a container tag deployed once on your site. Inside that container, you configure GA4 configuration tags and event tags using GTM's trigger and variable system. No plugin required after the initial GTM snippet is installed.

Install GTM on WordPress:

Option A — Manual: Add the GTM <head> snippet in your functions.php or a site-specific plugin using wp_head:

function add_gtm_head() {
    echo "<!-- 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 -->";
}
add_action('wp_head', 'add_gtm_head', 1);

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

Replace GTM-XXXXXXX with your container ID. Note that wp_body_open requires your theme to call wp_body_open() at the opening <body> tag — most modern themes do, but verify.

Option B — Use the GTM4WP plugin, which handles both the <head> and <body> snippet injection and adds a dataLayer push with WordPress-specific variables (post ID, post type, author, categories) that are useful for GA4 custom dimensions.

Inside GTM, configure GA4:

  1. Create a Google Analytics: GA4 Configuration tag with your Measurement ID. Set it to fire on All Pages.
  2. Disable "Send a page view event" if Enhanced Measurement page_view is already active — otherwise you'll see double page views.
  3. Create event tags for custom interactions (e.g., form submissions, button clicks) using GTM triggers.

Method 4: Manual Snippet in functions.php

For developers who want zero plugin overhead:

function add_ga4_snippet() {
    if ( is_user_logged_in() && current_user_can('manage_options') ) return;
    ?>
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-XXXXXXXXXX');
    </script>
    <?php
}
add_action('wp_head', 'add_ga4_snippet');

The is_user_logged_in() check excludes admin sessions from your data — a low-cost fix for a surprisingly common inflation source.

How to Configure Ecommerce Tracking for WooCommerce

GA4 ecommerce tracking requires firing specific events: view_item, add_to_cart, begin_checkout, purchase, and optionally view_item_list and remove_from_cart. None of these fire automatically from a standard WooCommerce installation.

Option 1 — MonsterInsights Pro: Handles all standard ecommerce events automatically. Enable under Insights → eCommerce → Use Enhanced eCommerce.

Option 2 — GTM + dataLayer: WooCommerce can push ecommerce data to the GTM dataLayer using a plugin like Duracell Tomi's GTM4WP (free) or DataLayer for WooCommerce (paid). GTM4WP includes a WooCommerce integration that pushes purchase events to the dataLayer on the order confirmation page. You then configure a GA4 event tag in GTM that reads from {{dlv - ecommerce}}.

The most common WooCommerce GA4 mistake is missing purchase events because the thank-you page URL (/order-received/) is not being reached — either due to a redirect misconfiguration or a payment gateway that returns to a custom page. Always validate in GA4 DebugView (Admin → DebugView) with a real test transaction before going live.

For context on broader WooCommerce analytics approaches, our WooCommerce analytics setup guide comparing GA4 vs native tools covers when native WooCommerce reports are sufficient and when GA4 is worth the integration complexity.

How to Set Up Conversions (Goals) in GA4

GA4 does not use "Goals" terminology — it uses Conversions, which are simply events you mark as conversion events.

  1. In GA4, go to Admin → Events
  2. Find the event you want to mark (e.g., purchase, generate_lead, form_submit)
  3. Toggle Mark as conversion

If the event hasn't fired yet (your site is new), you can create a Custom Event definition under Admin → Events → Create Event to map an existing event to a new name, then mark that as a conversion.

For contact form submissions, you need the form plugin to fire a GA4 event or GTM trigger on successful submission. Most major WordPress form plugins (Gravity Forms, WPForms, Fluent Forms) have native GTM/GA4 integration or webhook support for this. Our post on the best WordPress contact form plugin for performance and conversions covers which plugins handle this cleanly without additional configuration.

Common GA4 Configuration Mistakes on WordPress

1. Not Filtering Internal Traffic

Without an IP filter or developer traffic exclusion, your team's sessions inflate engagement metrics. In GA4, go to Admin → Data Streams → [stream] → Configure Tag Settings → Define internal traffic, then create a rule for your office IP range. Add traffic_type=internal as a parameter, then exclude it under Admin → Data Filters.

2. Double-Tracking via Multiple Snippets

If you use Site Kit AND have GTM deploying GA4, you'll double-count every event. Use GA4 DebugView or the Tag Assistant Chrome extension to verify only one GA4 configuration tag fires per page load.

3. Missing HTTPS/HTTP Parity

If your WordPress site serves pages on both http:// and https://, GA4 treats them as separate hostnames and your session data fragments. Ensure your site enforces HTTPS redirects — our complete WordPress SSL and HTTPS setup guide covers the NGINX and Apache configurations that prevent this.

4. Bot Traffic Inflation

WordPress sites are aggressively crawled. Without server-level bot filtering, bot sessions appear in GA4 as real traffic. GA4 has some bot filtering enabled by default, but it does not catch all crawler traffic. Platforms like TopSyde managed WordPress hosting apply server-level request filtering before traffic ever hits your application, reducing GA4 noise at the source.

5. Sampling in Explorations

GA4 Explorations (custom reports) are subject to sampling for high-traffic properties on free accounts. If you're seeing sampled data indicators in your reports, consider BigQuery Export (free tier available, linked under Admin → BigQuery Linking) to query unsampled raw event data.

Validating Your GA4 Implementation

Before relying on any data, run this checklist:

  • DebugView shows events firing in real time during a test session
  • Tag Assistant browser extension confirms one GA4 config tag per page, no duplicates
  • purchase event fires and includes transaction_id, value, and currency parameters
  • Internal traffic filter is configured and tested (visit site from office IP, confirm session appears under "internal" segment, then is excluded from main reports)
  • Conversion events are marked and appearing in Reports → Engagement → Conversions
  • Page view count in GA4 matches your server-side request logs within a reasonable margin (~5–15% variance is typical; higher suggests bot inflation or sampling)

According to a 2023 Simo Ahava analytics audit study across 200 sites, over 60% of GA4 implementations had at least one critical misconfiguration — most commonly duplicate tags or missing ecommerce events.

For teams managing GA4 across multiple client WordPress sites, the configuration complexity scales quickly. Our WordPress agency workflow guide covers how to systematize analytics deployment alongside other repeatable client deliverables.


Frequently Asked Questions

Do I need a plugin to add GA4 to WordPress?

No. You can manually add the GA4 gtag.js snippet to your theme's functions.php or a site-specific plugin using the wp_head action. Plugins like Site Kit and MonsterInsights simplify the process and add UI-based reporting, but they are not required and do add JavaScript overhead.

Why is my GA4 showing no data after setup?

The most common causes are: the Measurement ID is incorrect or mismatched between your data stream and your snippet; the snippet is firing inside a conditional that prevents it from loading; or you have a caching plugin serving a cached page that predates your GA4 snippet addition. Clear all caches after installing GA4 and verify with DebugView in an incognito window.

Does GA4 work with WordPress caching?

Yes, but full-page caching does not affect GA4 because gtag.js is client-side JavaScript — it fires in the browser after the cached HTML is delivered. The issue arises only if a plugin minifier or JavaScript combiner incorrectly modifies the GA4 snippet, breaking the gtag() function call.

What is the difference between GA4 events and conversions?

In GA4, all interactions are events. A conversion is simply an event you designate as a business-critical action in the GA4 Admin interface. Any event — including custom ones you define — can be marked as a conversion. This replaces the "Goals" system from Universal Analytics.

Should I use Google Tag Manager or a plugin for GA4 on WordPress?

Use Google Tag Manager if you have multiple tracking tags (GA4, Meta Pixel, LinkedIn Insight Tag, etc.), need custom event tracking, or want to make tag changes without deploying code. Use a plugin like MonsterInsights if you need WooCommerce ecommerce tracking quickly and want a WordPress-native configuration UI. Avoid running both simultaneously unless you've explicitly scoped which tool manages which tags.

Rachel Nguyen
Rachel Nguyen

Senior WordPress Engineer

8+ years WordPress & WooCommerce development

Rachel is a senior WordPress engineer at TopSyde specializing in WooCommerce performance and plugin architecture. She has built and maintained high-traffic e-commerce sites processing millions in annual revenue.

Related Articles

View all →

Stop managing your WordPress site

Let our team handle hosting, speed, security, and updates — so you can focus on what matters.

Get Started Free