How to Set Up Google Analytics 4 (GA4) in WordPress

November 6, 2025
How to Set Up Google Analytics 4 (GA4) in WordPress

Google Analytics 4 (GA4) is Google’s latest analytics platform, offering advanced tracking, cross-device measurement, and event-based data collection. If you want to monitor visitor traffic, engagement, and conversions on your WordPress site, GA4 is essential. This guide walks you through how to set up GA4 in WordPress — both manually and using plugins.


What Is Google Analytics 4 (GA4)?

GA4 is the new version of Google Analytics that replaces Universal Analytics (UA). Unlike UA, GA4 tracks user interactions as events instead of sessions, allowing for deeper insights into user behavior and better privacy compliance.

  • ✅ Tracks user activity across devices and platforms
  • ✅ Uses AI-driven insights and predictive analytics
  • ✅ Event-based model (scrolls, clicks, form submissions, etc.)
  • ✅ Integrates with Google Ads, Search Console, and BigQuery

Step 1: Create a GA4 Property

  1. Go to the Google Analytics dashboard.
  2. Click the Admin (⚙️) icon in the lower left corner.
  3. Under the Account column, choose your account or create a new one.
  4. Under the Property column, click + Create Property.
  5. Enter a name (e.g., “My WordPress Site”) → Select your time zone and currency → Click Next.
  6. Choose your business category and size → Click Create.

GA4 will now prompt you to set up a Data Stream.


Step 2: Set Up a Web Data Stream

  1. Click Web (for website tracking).
  2. Enter your website URL (e.g., https://example.com).
  3. Name your stream (e.g., “Main Website”).
  4. Click Create Stream.

After creation, you’ll see your Measurement ID — it starts with G- (e.g., G-XXXXXXXXXX). Keep this ID handy; you’ll use it in the next step.


Step 3: Add GA4 Tracking Code to WordPress

There are two ways to add GA4 tracking to your WordPress site — using a plugin or adding the code manually.


Option 1: Add GA4 Using a Plugin (Recommended)

Method A: Using “Site Kit by Google”

  1. Go to Plugins → Add New and search for Site Kit by Google.
  2. Click Install NowActivate.
  3. Click the Start Setup button.
  4. Sign in with your Google account and grant the requested permissions.
  5. Once connected, Site Kit automatically links your GA4 property and starts collecting data.

Advantages: Site Kit also connects Google Search Console, AdSense, and PageSpeed Insights — all in one dashboard.


Method B: Using “GA Google Analytics” Plugin

  1. Go to Plugins → Add New and search for GA Google Analytics.
  2. Install and activate the plugin.
  3. Go to Settings → Google Analytics.
  4. Paste your Measurement ID (e.g., G-XXXXXXXXXX) into the field.
  5. Save changes — your tracking code is now added site-wide.

Option 2: Add GA4 Code Manually

If you prefer not to use a plugin, you can insert the GA4 tracking script directly into your theme files.

  1. Copy your GA4 tracking code snippet from the Web Stream Details screen in Analytics.

The code looks like this:

<!-- Google tag (gtag.js) -->
<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>

Add this code right before the closing </head> tag in your theme’s header.php file, or use a code management plugin like Code Snippets or Insert Headers and Footers.


Step 4: Verify GA4 Tracking

Once you’ve added the code, check that GA4 is tracking properly:

  1. Go to your Google Analytics dashboard.
  2. Click Admin → Data Streams → Web → your stream.
  3. Click Realtime in the left sidebar.
  4. Open your website in another browser tab or device.
  5. If you see an active user count, GA4 tracking is working correctly.

Tip: You can also use the Google Tag Assistant Chrome extension to confirm installation.


Step 5: Configure Enhanced Measurement

GA4 includes Enhanced Measurement to automatically track key interactions such as:

  • 📄 Page views
  • 🔗 Outbound link clicks
  • 📥 File downloads
  • 🧭 Scrolls and engagement time
  • 📧 Site searches and form interactions

To verify these settings:

  1. In your GA4 property, go to Admin → Data Streams.
  2. Select your web stream.
  3. Ensure Enhanced Measurement is toggled ON.

Step 6: Add Conversion Events (Optional)

If you want to track specific goals such as form submissions, button clicks, or purchases, you can create custom events:

  1. Go to Admin → Events → Create Event.
  2. Click Create and define your event name and conditions.
  3. To mark it as a conversion, go to Configure → Conversions → click New Conversion Event and enter the same name.

Example: Track contact form submissions with event_name = form_submit.


Step 7: Link GA4 to Google Search Console (Optional)

To combine Analytics with SEO data:

  1. Go to Admin → Product Links → Search Console Links.
  2. Click Link and select your Search Console property.
  3. Choose your web data stream and click Submit.

After linking, you’ll get organic traffic reports inside GA4 under Reports → Acquisition → Search Console.


Step 8: Privacy and GDPR Compliance

GA4 is designed with privacy in mind, but it’s important to configure it properly to comply with GDPR or regional data protection laws.

  • 🔒 Enable IP anonymization (enabled by default in GA4).
  • ⚙️ Use a cookie consent plugin (e.g., Complianz or CookieYes).
  • 🧾 Update your privacy policy to mention data tracking via Google Analytics.

Step 9: Analyze Your Traffic

Once tracking is confirmed, explore GA4’s reports:

  • Reports → Realtime: See who’s on your site right now.
  • Reports → Engagement → Pages and Screens: Find your top-performing pages.
  • Reports → Demographics: Understand your visitors’ countries and devices.
  • Explore: Build custom funnel and path analysis reports.

Troubleshooting Common Issues

1) Data Not Showing in GA4

  • Wait up to 24 hours for initial data to appear.
  • Confirm your Measurement ID is correct.
  • Use Realtime view to test live traffic.

2) Duplicate Tracking

  • Ensure you’re not using multiple plugins injecting GA code.
  • Check your site source for duplicate gtag.js scripts.

3) Wrong Domain or Subdomain

  • Verify your property’s Stream URL matches your actual site domain.

Best Practices

  • ✅ Use Site Kit for easy setup and unified Google integrations.
  • ✅ Enable Enhanced Measurement for deeper analytics.
  • ✅ Track key conversions manually (forms, buttons, downloads).
  • ✅ Regularly review Realtime and Engagement reports.

Conclusion

Setting up Google Analytics 4 in WordPress only takes a few minutes, and it provides powerful insights into how users interact with your website. Whether you use Site Kit or a manual code insert, GA4 helps you monitor performance, track conversions, and make data-driven decisions to grow your audience.

Summary: Create GA4 property → Get Measurement ID → Add code via plugin or manually → Verify → Enable Enhanced Measurement → Track conversions.
You’re now ready to use GA4 for smarter website analytics.

Avatar

Written by

satoshi

I’ve been building and customizing WordPress themes for over 10 years. In my free time, you’ll probably find me enjoying a good football match.