Free SEO audit for new clients — claim yours
Home/Blog/Analytics/How to Set Up Google Analytics 4 on WordPress
Analytics

How to Set Up Google Analytics 4 on WordPress

How to Set Up Google Analytics 4 on WordPress
Table of contents
  1. Key Takeaways
  2. Step 1: Create your GA4 property and data stream
  3. Step 2: Choose your installation method
    1. Option A: Site Kit by Google
    2. Option B: Google Tag Manager
    3. Option C: Manual code
  4. Step 3: Verify data is flowing
  5. Step 4: Configure what matters after installation
  6. Consent and privacy
  7. Common mistakes when adding GA4 to WordPress
  8. Related Guides
  9. Frequently Asked Questions
    1. Do I need a plugin to add GA4 to WordPress?
    2. Is Site Kit or Google Tag Manager better?
    3. Why is GA4 showing double page views on my WordPress site?
    4. How long until data appears in GA4?
    5. Can I track WooCommerce sales with GA4?
  10. Conclusion
  11. References

Installing Google Analytics 4 on WordPress looks like a five-minute job, and technically it is. The problems start later: duplicate tags firing twice, a theme update that silently wipes your code, forms that never show up as leads, or months of data polluted by your own visits.

This guide walks through the four reliable ways to add GA4 to WordPress, helps you pick the right one for your site, and covers the checks that separate a working install from an accurate one. You will learn how to create the property, connect it to WordPress, verify that data is flowing and configure the events that matter for your business.

If you are new to GA4 itself, our complete GA4 guide explains the reports and data model; this post focuses on the WordPress side.

Key Takeaways

  • Create the GA4 property and web data stream first; you need its Measurement ID (starts with "G-").
  • Use only one installation method. Two methods running together will double-count page views.
  • Site Kit is easiest for small sites; Google Tag Manager is best when you need custom events and multiple tags.
  • Never paste code into a parent theme's header.php; updates will remove it.
  • Verify with the Realtime report and DebugView, then set up key events and internal traffic filters.

Step 1: Create your GA4 property and data stream

Before touching WordPress, set up Analytics. According to Google's setup guide, the process is:

  1. Sign in to Google Analytics and open Admin. Create an account if you do not have one.
  2. Create a property: name it, choose your reporting time zone and currency, and answer the business questions.
  3. Add a web data stream with your site URL and a stream name. Leave enhanced measurement switched on unless you have a reason not to.
  4. Copy the Measurement ID from the stream details. It begins with "G-".

Getting the time zone and currency right matters: they affect how days are split in reports and how revenue is shown.

Step 2: Choose your installation method

There are four common ways to connect GA4 to WordPress. Semrush's WordPress analytics guide covers the same options, including the built-in field on WordPress.com paid plans. Here is how they compare:

MethodBest forProsCons
Site Kit by Google pluginSmall business sites, beginnersOfficial Google plugin, no code, shows Search Console and PageSpeed data in WordPressLimited control over custom events
Google Tag ManagerLead-gen, ecommerce, sites with many tagsCustom events, form tracking, ads tags and consent in one placeLearning curve; easy to misconfigure
Manual Google tag in child theme or header pluginDevelopers, lightweight sitesNo extra plugin overhead, full controlCode can be lost on theme changes; events need more code
WordPress.com built-in integrationWordPress.com hosted plans that include itPaste the Measurement ID into one fieldPlan-dependent; limited customisation

Option A: Site Kit by Google

Site Kit is Google's own plugin. Its WordPress.org listing shows more than five million active installations at the time of writing, and describes it this way:

“Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.”

— WordPress.org, Site Kit by Google plugin listing
  1. In WordPress, go to Plugins → Add New, search for "Site Kit by Google", install and activate it.
  2. Start setup and sign in with the Google account that has access to your Analytics property.
  3. Verify site ownership and allow the requested permissions.
  4. Connect Analytics and select your existing GA4 property and web stream (or let Site Kit create one).
  5. Optionally connect Search Console and PageSpeed Insights for dashboards inside WordPress.

Option B: Google Tag Manager

If you plan to track form submissions, phone clicks, ads conversions or third-party pixels, GTM is the more scalable choice. Install the GTM container code (head and body snippets) through a header/footer plugin or your theme's hooks, then create a Google tag in GTM with your Measurement ID, triggered on all pages. Our Google Tag Manager guide covers containers, triggers and publishing in detail.

Option C: Manual code

In Analytics, the stream's "Install manually" instructions give you the Google tag snippet. Add it immediately after the opening head tag using a child theme's functions.php with the wp_head hook, or a trusted header-code plugin:

add_action( 'wp_head', function () { ?>
<!-- Paste the Google tag snippet from GA4 here -->
<?php }, 1 );

Never edit the parent theme directly; the next theme update will overwrite your changes. Back up the site before editing PHP.

Step 3: Verify data is flowing

Once installed, check that GA4 receives exactly one set of hits:

  • Open your site in a private window and look at Reports → Realtime. Google notes data can take a short while to appear.
  • Use Tag Assistant or GTM Preview to confirm the tag fires once per page. Two page_view events per load means two installs.
  • Open Admin → DebugView to watch events in detail while in debug mode.
  • View the page source and search for your "G-" ID to spot duplicate snippets left by old plugins or themes.

Step 4: Configure what matters after installation

A default install only tells you about visits. To make GA4 useful for a WordPress business site, finish these settings:

SettingWhy it mattersWhere to learn more
Key events (leads, purchases, bookings)Turns traffic into business outcomesGA4 key events
Form submission trackingMost WordPress form plugins need extra setupTrack form submissions
Internal traffic filterRemoves your team's visitsExclude internal traffic
Ecommerce events (WooCommerce)Revenue, product and checkout reportsGA4 ecommerce tracking
Data retentionControls how long user-level data is kept for explorations; review the defaultAdmin → Data settings
Search Console linkBrings query data into GA4See organic keywords in GA4

If you have visitors from the EU, UK or other regions with consent rules, load analytics in line with your consent banner. Many WordPress consent plugins support Google Consent Mode, which adjusts how Google tags behave based on the visitor's choice. Test the banner after installing GA4: accept, reject and check what fires in each case.

Common mistakes when adding GA4 to WordPress

  • Double installation. Site Kit plus a manual snippet plus a theme's built-in analytics field equals inflated page views and a broken bounce/engagement picture.
  • Editing the parent theme. Code disappears on the next update, often unnoticed for weeks.
  • Caching plugins serving old HTML. Clear page and CDN caches after adding or removing tags.
  • Tracking staging sites. Keep your staging environment out of production data; see our note on staging site SEO.
  • Skipping key events. Without them, GA4 cannot tell you which pages or channels generate leads.
  • Ignoring page speed. Every extra plugin and tag adds weight; review what you load with our guide to third-party scripts.

Frequently Asked Questions

Do I need a plugin to add GA4 to WordPress?

No. You can add the Google tag manually through a child theme or use Google Tag Manager. A plugin such as Site Kit simply makes setup easier for non-developers.

Is Site Kit or Google Tag Manager better?

Site Kit suits simple sites that only need standard reporting. Google Tag Manager is better if you need form tracking, ads conversion tags or several marketing pixels.

Why is GA4 showing double page views on my WordPress site?

Usually two installation methods are active at once, such as a plugin and a manual snippet. Remove one and confirm with Tag Assistant that only one page_view fires per load.

How long until data appears in GA4?

Realtime data usually shows within minutes. Standard reports can take longer to process, so check Realtime and DebugView first.

Can I track WooCommerce sales with GA4?

Yes, but it needs ecommerce events such as purchase with item data. Use a dedicated integration or GTM data layer rather than relying on page views.

Conclusion

Adding GA4 to WordPress takes minutes, but accurate measurement takes a little more care: one installation method, verified tags, clear key events and clean filters. Get those right and every SEO, content and ads decision becomes easier. If you would like experts to set up and audit your analytics alongside a WordPress growth plan, see our SEO services or get a quote.

References

  1. Google Analytics Help: Set up Analytics for a website and/or app
  2. WordPress.org: Site Kit by Google
  3. Site Kit by Google
  4. Google Analytics Help: Monitor events in DebugView
  5. Semrush: Google Analytics WordPress Setup
Rohit Choudhary
Written byRohit ChoudharyCo-Founder, My SEO Experts

Rohit Choudhary is the co-founder of My SEO Experts and has more than 14 years of hands-on experience in SEO, paid advertising and digital marketing. Since starting out in 2011 he has helped hundreds of businesses grow through practical, data-driven search strategies, and he also serves as a consulting Digital Marketing Director for several US-based companies.

Keep reading

Related articles

How to See Organic Search Keywords in GA4
Analytics

How to See Organic Search Keywords in GA4

Why organic keywords are missing from GA4, how to link Search Console to see them, where to find the reports, and how to work around the data's limits.

Ready to grow your business online?

Get a free, no-obligation proposal tailored to your goals and budget.

CallFree Quote