How to Add Google Analytics 4 to WordPress: 3 Methods Compared | Simple Automation Solutions








WordPress Development

How to Add Google Analytics 4 to WordPress: 3 Methods Compared

GA4 is the only way to understand how visitors use your site. Here are the three methods for connecting it to WordPress — with a clear recommendation for each type of user.

SAS

Simple Automation Solutions

·

·
⏱ 9 min read

GA4
current Google Analytics version
Free
to set up and use
30s
to verify live in Realtime
3
methods — plugin, code, GTM

You cannot improve what you do not measure. Google Analytics 4 tells you where your visitors come from, which pages they read, how long they stay, and what actions they take. This guide covers every method for connecting it to WordPress — and which one to use.

What is Google Analytics 4 and why upgrade from UA?

Google Analytics 4 (GA4) is the current version of Google Analytics. Universal Analytics (UA) was permanently shut down on 1 July 2024 — if you are still seeing UA data anywhere, it is historical. All new tracking must be done through GA4.

GA4 uses an event-based data model instead of UA’s session-based model. Every interaction — page view, scroll, click, form submission, video play — is tracked as an event with associated parameters. This gives you significantly more granular data about how users actually engage with your content.

Step 1 — Create your GA4 property

1
Go to analytics.google.com

Sign in with your Google account. If you are new to Analytics, click ‘Start measuring’. If you have an existing account, click the gear icon (Admin) in the bottom left.

2
Create a new property

Click ‘Create Property’. Enter your website name, select your reporting time zone and currency, then click Next. Fill in your business details and click Create.

3
Set up a Web data stream

Select ‘Web’ as your platform. Enter your website URL and stream name. Click ‘Create stream’. You will see your Measurement ID — it looks like G-XXXXXXXXXX. Copy it. You need this for all three methods below.

Method 1 — Plugin (recommended for most sites)

A dedicated plugin is the simplest, most reliable method. It handles the code insertion correctly and usually adds enhanced measurement features on top of the standard GA4 tag.

Free — Best Option
Google Site Kit
Official plugin by Google. Connects GA4, Search Console, PageSpeed Insights, and AdSense in one dashboard. Verifies your site with Google automatically. Recommended for beginners.
Free / Premium
MonsterInsights
Shows GA4 data directly inside your WordPress dashboard. Tracks forms, WooCommerce, and custom events without code. The most feature-rich GA4 plugin for WordPress.
Free
GA Google Analytics
Lightweight plugin — just inserts the GA4 tag. No frills, minimal overhead. Good for advanced users who only need the basic tag inserted.
1
Install your chosen plugin

Go to Plugins → Add New, search for your chosen plugin, install and activate it.

2
Connect your Google account

Follow the plugin’s setup wizard. You will be prompted to sign in with Google and grant permissions to access your Analytics account.

3
Select your GA4 property

Choose the GA4 property you created in Step 1. The plugin will insert the tracking code on every page of your site automatically.

4
Verify tracking is working

Open your website in a browser, then go to GA4 → Reports → Realtime. You should see your visit appear within 30 seconds. If you see data, tracking is live.

Method 2 — Manual code in your theme

If you prefer not to use a plugin, you can insert the GA4 tracking code directly into your theme’s header. This is the lightest-weight method — no plugin overhead — but it requires a child theme so the code is not erased when your theme updates.

⚡ Prerequisite

You must be using a child theme before adding code to functions.php or header.php. If you add code to your parent theme files directly, a theme update will delete it. See our WordPress Child Themes guide for setup instructions.

1
Copy your GA4 code snippet

In GA4, go to Admin → Data Streams → your stream → View tag instructions. Copy the full JavaScript snippet — it starts with .

2
Add the code to your child theme’s functions.php

Open your child theme’s functions.php and add this function: wp_head() fires the snippet on every page inside the tag, which is exactly where GA4 needs to load.

3
Or paste directly into header.php

Alternatively, open your child theme’s header.php, find the closing tag, and paste the GA4 snippet immediately before it.

4
Verify in GA4 Realtime

Visit your site and check GA4 → Realtime to confirm the tag is firing correctly.

💡 Use functions.php, not header.php

Adding code via functions.php using wp_enqueue or wp_head hooks is cleaner than editing header.php directly. It keeps your tracking code separate from your template markup and is easier to manage.

Method 3 — Google Tag Manager

Google Tag Manager (GTM) is a tag management system that lets you deploy and manage tracking scripts from a single web interface — without editing your website code every time you add a new tag. It is the professional standard for sites with multiple tracking needs.

With GTM, you install one GTM container snippet on your site (via plugin or manual code). Every subsequent tracking tag — GA4, Facebook Pixel, LinkedIn Insight, custom event tracking — is managed from the GTM dashboard without touching WordPress at all.

  • Best for: sites running multiple tracking scripts, agencies managing multiple clients, or anyone who needs to add/modify tracking frequently
  • Use the GTM4WP plugin to insert the GTM container code into WordPress correctly (including the noscript fallback)
  • Once GTM is installed, add GA4 as a tag inside GTM using the ‘Google Tag’ template with your Measurement ID
  • GTM adds a small amount of page load overhead — for most sites it is negligible, but plugin-based GA4 is slightly faster

Verify enhanced measurement events

GA4 automatically tracks several events beyond page views — called Enhanced Measurement. After setup, verify these are enabled in GA4:

Event What it tracks Status
page_view Every page load Auto — always on
scroll User scrolls 90% of a page On by default
click Outbound link clicks On by default
file_download PDF, doc, zip downloads On by default
form_submit Contact form completions Requires MonsterInsights or custom setup
purchase WooCommerce transactions Requires MonsterInsights Pro or custom setup

Need your WordPress site set up with full analytics tracking?

Simple Automation Solutions configures GA4, Search Console, and conversion tracking for WordPress sites worldwide — so you see exactly what is working.

Frequently asked questions

Does adding Google Analytics slow down my WordPress site?+

GA4 tracking adds a small amount of JavaScript to every page — typically 30–45KB. The impact on page speed is minimal when loaded asynchronously (which all three methods above do by default). Using a caching plugin (WP Rocket) ensures the GA4 script loads without blocking page rendering.

How do I check if GA4 is tracking correctly on my WordPress site?+

The fastest check is GA4’s Realtime report — open your website in a browser and watch the Realtime report in GA4. Your session should appear within 30 seconds. For a more thorough check, install the Google Tag Assistant Chrome extension, which shows all active tags on your page and their status.

Should I use Google Site Kit or MonsterInsights?+

Both are excellent. Site Kit is better if you want a free, official solution that also shows Search Console and PageSpeed data inside WordPress. MonsterInsights is better if you want detailed analytics data (top pages, referral sources, ecommerce) visible directly inside your WordPress dashboard without opening GA4 separately.

SAS
Simple Automation Solutions
Global WordPress Development Studio · Pakistan

Simple Automation Solutions is a global digital product studio specialising in WordPress and Bubble.io development. We serve founders, startups, and businesses worldwide — delivering production-ready websites, web apps, and MVPs built to rank, convert, and scale.


Simple Automation Solutions

Business Process Automation, Technology Consulting for Businesses, IT Solutions for Digital Transformation and Enterprise System Modernization, Web Applications Development, Mobile Applications Development, MVP Development

Copyright © 2026