How to Add GA4 to WordPress: A Complete Guide

How to Add GA4 to WordPress: A Complete Guide

  • Post category:SEO

If you’re running a WordPress website, tracking your visitors and understanding their behavior is essential for growing your online presence. One of the most powerful tools available is Google Analytics 4 (GA4) — Google’s latest analytics platform that replaces Universal Analytics.

We’ll walk you through how to add GA4 to WordPress, step-by-step, with both plugin and manual options. By the end, you’ll have GA4 set up and working seamlessly with your WordPress site.

What Is GA4 and Why Do You Need It?

GA4 is the latest version of Google Analytics. Unlike Universal Analytics (UA), GA4 uses an event-based model instead of sessions, offering more flexibility, better user tracking across devices, and advanced reporting. It’s also built to be more privacy-friendly and future-proofed against cookie deprecation.

Whether you run a blog, eCommerce store, or business website, setting up GA4 gives you insights like:

  • Where your visitors come from
  • What pages they view most
  • How long they stay
  • Which buttons they click
  • Which traffic sources drive the most conversions

Step 1: Create a Google Analytics 4 Property

Before adding GA4 to WordPress, you’ll need to create a GA4 property in your Google Analytics account.

Here’s how:

  1. Log in to your https://analytics.google.com/ account.
  2. Click “Admin” on the left sidebar.
  3. Under the Account column, select your website account or create a new one.
  4. Under the Property column, click “Create Property.”
  5. Name your property, set your time zone and currency, and click “Next.”
  6. Choose your business category and hit “Create.”

You’ll now be redirected to a page with your Measurement ID — it will look something like G-XXXXXXXXXX. You’ll use this in the next steps.

Step 2: Add GA4 to WordPress (3 Easy Methods)

You can connect GA4 to WordPress using three main methods:

✅ Method 1: Using a Plugin (Recommended for Beginners)

The easiest and most beginner-friendly way is using a plugin like Site Kit by Google or MonsterInsights.

Option A: Site Kit by Google (Free)

Steps:

  1. Go to your WordPress dashboard.
  2. Navigate to Plugins > Add New.
  3. Search for Site Kit by Google and click Install Now, then Activate.
  4. Launch Site Kit setup and connect it with your Google account.
  5. During the setup, you’ll have the option to connect Google Analytics.
  6. Site Kit will automatically detect your GA4 property and connect it — no manual coding needed.

This method is ideal because it integrates GA4, Google Search Console, PageSpeed Insights, and AdSense — all from one dashboard.

Option B: MonsterInsights (Freemium)

MonsterInsights is another popular plugin that simplifies GA4 setup.

  1. Install and activate the MonsterInsights plugin.
  2. Use the setup wizard to connect your Google account.
  3. It will prompt you to choose a GA4 property — simply select the one you created.
  4. MonsterInsights adds the GA4 tracking code automatically.

Note: Advanced features like custom dimensions and eCommerce tracking require the Pro version.

✅ Method 2: Manual Insertion of GA4 Code (For Developers)

If you prefer a hands-on approach or want to reduce plugin use:

  1. Copy your GA4 Measurement ID (G-XXXXXXXXXX).
  2. Go to Google Analytics > Admin > Data Streams > Web.
  3. Find your Web Stream and click View Tag Instructions.
  4. Copy the global site tag (gtag.js) code.
  5. Paste this code into your WordPress site’s header.php file:
<head>
  <!-- Add the GA4 gtag code before the closing head tag -->
  <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>
</head>

Be sure to replace G-XXXXXXXXXX with your actual GA4 Measurement ID.

Pro Tip: Use a child theme when editing theme files directly to prevent data loss during theme updates.

✅ Method 3: Use a Tag Manager (Advanced Users)

For marketers or larger websites, using Google Tag Manager (GTM) is ideal:

  1. Set up a GTM container for your WordPress site.
  2. Install the GTM code snippets into your site’s <head> and <body> sections.
  3. In GTM, create a GA4 Configuration tag with your Measurement ID.
  4. Publish your GTM container.

GTM allows you to manage all tracking codes — GA4, Facebook Pixel, remarketing — from one place without modifying your site code.

How to Confirm GA4 Is Working on Your Site

Once installed, always check if GA4 is properly tracking:

  1. Go to your Google Analytics > Realtime tab.
  2. Visit your website in a new browser or incognito window.
  3. You should see an active user on the GA4 Realtime dashboard.

You can also use the Google Tag Assistant Chrome extension or the GA Debugger extension to validate installation.

FAQs

Q: Can I use both GA4 and Universal Analytics?
A: Universal Analytics was sunset in 2023. GA4 is now the default and only supported version.

Q: Is GA4 free?
A: Yes, GA4 is free. Google also offers a premium GA4 360 version for enterprise users starting at ~$50,000/year.

Q: Which plugin is best for adding GA4 to WordPress?
A: Site Kit by Google is highly recommended for beginners due to its simplicity and native support.