How to Add Google Analytics to WordPress (2026)
Learn how to add Google Analytics to WordPress three ways — Site Kit plugin, manual GA4 tag, or Google Tag Manager — with GA4 setup and verification.
Google Analytics answers the questions every site owner eventually asks: how many people visit, where they come from, which pages they read, and what makes them convert. It’s free, it’s the most widely used analytics platform on the web, and connecting it to WordPress takes about ten minutes.
The current version is Google Analytics 4 (GA4). The older Universal Analytics has been fully retired — it stopped processing data in 2023 and its interface was shut down in 2024 — so any setup you do today uses GA4. If you find an old tutorial referencing “UA-” tracking IDs or Universal Analytics properties, ignore it; those no longer work.
This guide covers three ways to add Google Analytics to WordPress: the official Site Kit plugin (easiest), adding the GA4 tag manually, and using Google Tag Manager. We’ll also create the GA4 property first, verify data is flowing, and cover the privacy step you can’t skip in the EU.
Step 1: Create a GA4 Property
No matter which installation method you choose, you need a GA4 property and its Measurement ID first.
- Go to analytics.google.com and sign in with a Google account.
- Click Admin (the gear icon, bottom left).
- Under the Account column, create an account if you don’t have one, then click Create → Property.
- Name the property (usually your site name), set the time zone and currency, and click Next.
- Answer the business questions, then choose Web as your platform.
- Enter your website URL and a stream name, then click Create stream.
You’ll land on a Web stream details screen showing a Measurement ID that looks like G-XXXXXXXXXX. That ID is what connects WordPress to this property. Keep the tab open — you’ll need it shortly.
If you want a deeper walkthrough of GA4’s structure, reports, and terminology, our GA4 for WordPress guide goes further than we can here.
Method 1: Site Kit by Google (Recommended)
Site Kit is Google’s own official WordPress plugin. It connects Analytics, Search Console, PageSpeed Insights, and AdSense, and surfaces key stats right inside your WordPress dashboard. Because it’s built by Google, the GA4 connection is authenticated through your Google account rather than pasted-in code — which means fewer mistakes.
Install and Activate
- In your WordPress dashboard, go to Plugins → Add New Plugin.
- Search for Site Kit by Google.
- Click Install Now, then Activate.
- A “Site Kit” item appears in your admin menu. Click it and choose Start setup.
Connect Your Google Account
- Click Sign in with Google and choose the account that owns your GA4 property.
- Grant Site Kit the permissions it requests (verifying site ownership and reading Analytics data).
- Site Kit will verify ownership of your site and, in most cases, set up Search Console automatically.
Set Up GA4
- Back in Site Kit → Settings (or during the guided setup), click Connect Google Analytics.
- Site Kit detects the Analytics accounts and properties available to your Google login.
- Select the account, the GA4 property, and the web data stream you created in Step 1.
- Confirm, and Site Kit inserts the GA4 tracking code for you — no editing files.
That’s it. Within a day or two, a traffic summary appears on your WordPress dashboard, and full reports remain available in the Google Analytics interface itself.
Other Plugin Options
Site Kit is the cleanest free route, but two popular alternatives exist:
- MonsterInsights connects GA4 and adds dashboard reports, plus checkbox setup for ecommerce and outbound-link tracking. The free tier covers the basics; the useful automation lives in the paid tiers.
- Analytify focuses on presenting Analytics data in a friendly, readable dashboard inside WordPress, with front-end and per-post stats. It’s also freemium.
All three do the same core job — get the GA4 tag on your pages and pull reports back in. Site Kit wins on being free and first-party; the others compete on presentation and convenience features. If you’re weighing whether Google Analytics is even the right fit, see our roundup of the top 10 website analytics tools.
Method 2: Add the GA4 Tag Manually
If you’d rather not run another plugin, or you want full control, you can add the GA4 tag directly. The tag is a small snippet Google gives you; it needs to load in the <head> of every page.
Get the Snippet
In your GA4 property, go to Admin → Data streams → [your web stream] → View tag instructions → Install manually. Copy the Google tag code block. It starts with <!-- Google tag (gtag.js) --> and contains your G-XXXXXXXXXX ID.
Add It With a Code Snippets Plugin (Safest)
The cleanest manual method is a header-and-footer or code-snippets plugin, which survives theme updates and doesn’t require touching template files:
- Install and activate WPCode (formerly “Insert Headers and Footers”) from Plugins → Add New Plugin.
- Go to Code Snippets → Header & Footer.
- Paste the GA4 tag into the Header box.
- Click Save Changes.
Because the snippet lives in the plugin’s own storage rather than a theme file, switching or updating your theme won’t wipe it out.
Editing Theme Files Directly (Riskier)
You can add the tag by editing your theme’s header.php and placing the snippet just before the closing </head> tag — but be careful:
- Always use a child theme. If you paste code into a parent theme’s
header.php, the next theme update overwrites it and your tracking silently disappears. - A small syntax error can break your site. Editing PHP through Appearance → Theme File Editor with no safety net can produce a white screen. Edit via SFTP or your host’s file manager where you can quickly revert.
- Block themes may not have a
header.phpto edit at all, which makes a code-snippets plugin the more reliable choice on modern themes.
For most people, the WPCode route gives you the “manual” control without the fragility of editing theme files. Reserve direct theme edits for when you’re comfortable with PHP and working in a child theme.
Method 3: Use Google Tag Manager
Google Tag Manager (GTM) is a free container that loads and manages all your tags — Analytics, ad pixels, conversion tracking — from one interface, without adding each one to your site’s code. It’s more setup up front, but it pays off once you’re juggling several tracking tools.
- Create a container at tagmanager.google.com and choose Web as the target platform.
- GTM gives you two snippets — one for
<head>and one immediately after the opening<body>tag. Add both using WPCode (it has dedicated Header and Body fields) or a GTM-specific plugin. - In the GTM interface, click Tags → New → Google Analytics: GA4 Configuration.
- Paste your
G-XXXXXXXXXXMeasurement ID. - Set the trigger to All Pages so it fires site-wide.
- Click Submit in the top right to publish the container.
From then on, you add future tags (a WooCommerce purchase event, a Facebook pixel, a newsletter conversion) inside GTM without ever touching WordPress again. If you sell online, GTM is a natural fit for the event setup described in our guide to track WooCommerce conversions.
Step 2: Verify Data Is Flowing
Whichever method you used, confirm GA4 is actually receiving data before you move on. The fastest check is the Realtime report:
- Open your site in a separate browser tab (an incognito window is ideal, so you’re counted as a fresh visitor).
- In Google Analytics, go to Reports → Realtime.
- Within a few seconds you should see at least one active user — you — along with the page you’re viewing.
If you see yourself in Realtime, the tag is installed correctly. Standard reports like Acquisition and Engagement take 24–48 hours to populate, so don’t worry if they’re empty on day one.
If Realtime shows nothing after a few minutes, common culprits are: an ad blocker or privacy extension blocking the Analytics script (disable it to test), the wrong Measurement ID, a caching plugin serving an old page (clear your cache), or a consent banner blocking the tag until the visitor accepts.
Privacy: You Probably Need a Consent Banner
Google Analytics sets cookies and processes visitor data, which brings it under privacy laws like the EU’s GDPR and the ePrivacy Directive. In the EU and UK, you generally need prior consent before GA4 loads — a cookie banner where the visitor opts in, not just a notice that analytics is running.
Practically, that means:
- Add a consent management plugin (for example, Complianz or CookieYes) that blocks the GA4 tag until the visitor accepts.
- Publish a privacy policy explaining what you collect and why.
- Consider enabling IP anonymization and adjusting data-retention settings inside GA4.
This is a real legal obligation, not an optional nicety, if you have EU or UK visitors — which most sites do. For the full picture, including cookie-free setups that reduce this burden, read our guide to privacy-friendly analytics for WordPress. And if the compliance overhead makes GA4 feel like more than you need, our comparison of Google Analytics alternatives for WordPress covers lighter, consent-free options.
Which Method Should You Choose?
- Most WordPress users: Site Kit by Google. It’s free, official, and gets reports into your dashboard with the least room for error.
- Minimalists who dislike extra plugins: the manual GA4 tag via WPCode. One lightweight snippet, no ongoing plugin overhead.
- Sites running multiple tracking tools: Google Tag Manager, so you manage everything from one container.
There’s no wrong answer — all three put the same GA4 tag on your pages. Pick the one that matches how hands-on you want to be.
FAQ
Is Google Analytics free for WordPress?
Yes. GA4 is completely free for the vast majority of sites, and the plugins that connect it — Site Kit, the free tiers of MonsterInsights and Analytify, and WPCode — cost nothing. Google offers a paid enterprise version (Analytics 360), but ordinary WordPress sites never need it.
Do I still need Universal Analytics?
No. Universal Analytics is fully retired — it stopped collecting data in July 2023 and its interface was shut down in 2024. GA4 is the only current version. Any old “UA-” tracking ID no longer works, so every new install today uses a GA4 property and a G-XXXXXXXXXX Measurement ID.
Can I use more than one method at the same time?
You shouldn’t. Installing the GA4 tag through both Site Kit and a manual snippet, for example, can cause double-counting — every pageview and event fires twice, inflating your numbers. Choose one installation method per property and remove any others.
How long before I see data in Google Analytics?
The Realtime report shows your own visit within seconds, which is how you confirm the setup works. Standard reports such as Acquisition, Engagement, and Landing Pages take 24 to 48 hours to populate, so a fresh property will look empty at first even when tracking is working correctly.
Do I need a cookie consent banner for Google Analytics?
If you have visitors in the EU or UK, yes — GA4 uses cookies and processes personal data, so privacy law generally requires opt-in consent before it loads. Use a consent management plugin to block the tag until the visitor accepts, and publish a privacy policy. Sites with no such visitors have fewer obligations, but a clear privacy notice is still good practice.