Learning how to add Google Analytics to WordPress is one of the smartest first steps after launching your site. Google Analytics is a free tool that shows you exactly who visits your website, where they come from, which pages they read, and what they do before leaving. Without it, you are running your site blind — guessing instead of knowing.
The good news: connecting Google Analytics to WordPress takes about 15 minutes and requires zero coding. This guide walks you through two methods — using a plugin (easiest) and adding the tracking code manually (more control). Pick the one that fits you and follow along. Either way, you will finish with working tracking and a way to check it is actually recording visits.
What Is Google Analytics and Why Does Your Site Need It?
Google Analytics (now in its GA4 version) is a free service from Google. You add a small tracking code to your site, and it collects visitor data that appears in a dashboard. It answers questions like:
- How many people visited my site today, this week, or this month?
- Which of my posts get the most traffic?
- Do visitors come from Google search, social media, or somewhere else?
- How long do people stay before leaving?
- Which pages do visitors leave from, and which ones keep them reading?
Why does this matter? Data replaces guessing. If you know your tutorial posts get 10x more traffic than your opinion pieces, you write more tutorials. If 70% of visitors leave your homepage after five seconds, you know something needs fixing. Checking analytics weekly is the feedback loop that turns a hobby blog into a growing site — and it is the same data that advertisers and ad networks ask about when you apply for monetisation later.
GA4 replaced the older Universal Analytics in 2023, so if you followed an old tutorial and see a tracking ID starting with “UA-“, that method no longer works. GA4 uses a Measurement ID starting with “G-“, and the setup below is built for that version. The interface looks different from the old one, but the core idea is unchanged: a small code snippet on your pages, and a dashboard that turns visits into readable reports.

Before You Start: What You Need
You only need two things, both free:
- A Google account — the one you use for Gmail works fine. Use the account you plan to keep long term, because moving an Analytics property to a different Google account later is awkward.
- Admin access to your WordPress site — so you can install plugins or add code, depending on the method you choose.
One important note: you need a self-hosted WordPress site (WordPress.org) for both methods below. The free WordPress.com plan does not allow Google Analytics. Paid WordPress.com plans do allow it. If you have not set up WordPress yet, our guide on how to install WordPress manually covers the full process, and if your site is already live, check that you are logged in as an administrator before you start — an editor-level account cannot install plugins.
Step 1: Create Your Google Analytics Account
Set up the analytics account first — this part is identical no matter which installation method you choose. Keep the tab open when you finish, because you will need the Measurement ID in the next step.
- Go to analytics.google.com and sign in with your Google account.
- Click Start measuring (or the Admin gear icon if you already have an account).
- Enter an Account name — usually your business or website name. One account can hold several properties, so use a name that works if you add a second site later.
- Create a Property: give it your site’s name, then pick your reporting time zone and currency. The time zone matters — reports group visits by day according to this setting, and changing it later does not rewrite old data.
- Choose Web as your platform, enter your website URL (with https://), and a stream name like “My Main Site”.
- Click Create stream. Google will generate a Measurement ID that looks like
G-XXXXXXXXXX. Keep this tab open — you will need it next.
The Measurement ID is the key that links your website to your analytics property. Every method below is just a different way of telling Google, “this code belongs to my site.” Write the ID down somewhere safe as well — you will need it again if you ever switch plugins or rebuild the site.
Method 1: Use a Plugin (Easiest — Recommended)
The simplest way to connect Google Analytics to WordPress is with a plugin. It places the code for you, so there is nothing to break, and it keeps the code in place when you change themes — something the manual method does not do on its own.
- In your WordPress dashboard, go to Plugins → Add New.
- Search for “Site Kit by Google” — Google’s official plugin, free and well-maintained.
- Click Install Now, then Activate.

- Go to Site Kit → Dashboard and click Start Setup.
- Sign in with the Google account that owns your Analytics property and grant the permissions it asks for.
- Verify site ownership (usually automatic — Site Kit handles it).
- Toggle on Analytics and select the property you created in Step 1.
- Click Configure Analytics. Done.
Why Site Kit is great for beginners: the tracking code lands correctly on every page automatically, and your key stats show right inside the WordPress dashboard — no extra tab needed. Site Kit also connects Search Console if you set that up, so you can see search traffic and analytics side by side in one place.
Alternative: MonsterInsights is the most popular third-party analytics plugin. Its free version adds extras like outbound link and download tracking out of the box. It is a good choice if you want more detail inside WordPress itself, though the free version puts some reports behind an upgrade prompt. Whichever plugin you choose, install only one analytics plugin — two of them will double-count every visitor.
Method 2: Add the Tracking Code Manually (More Control)
Prefer not to add another plugin? Paste Google’s tracking snippet yourself. It takes a bit more care, but keeps your plugin count low and gives you full control over exactly where the code sits.
- In Google Analytics, go to Admin → Data Streams → your web stream and open View tag instructions.
- Copy the Google tag (gtag.js) snippet — a small JavaScript block containing your Measurement ID.
- Install the free WPCode plugin (formerly Insert Headers and Footers) from Plugins → Add New.
- Go to Code Snippets → Header and Footer in WPCode and paste the snippet into the Header field.
- Click Save Changes.
Paste the tracking code in the <head> section so it loads before the content. Code placed in the footer can miss visitors who leave before the page finishes loading.
The old way of doing this was editing your theme’s header.php directly through Appearance → Theme File Editor. Do not do that any more. Theme edits get wiped on every theme update, and one misplaced character in header.php can take the whole site down with a white screen. WPCode stores the snippet separately, so it survives theme updates and theme changes alike. That is the manual method I actually recommend.
Performance note: every third-party script adds a little load time. The analytics snippet is tiny and loads asynchronously, so the impact is negligible — but if speed is a priority, our guide on how to fix WordPress 500 internal server errors and our broader site-speed advice will help you keep scripts from hurting your rankings. A slow site loses visitors before analytics can even record them.
Step 2: Verify That Tracking Is Working
After installing by either method, confirm data is actually flowing. This is the step most people skip, and it is the one that catches the silent failures — a wrong Measurement ID, a caching plugin serving an old page, or a consent banner blocking the script.
- Open your site in a private/incognito browser window and visit a couple of pages. Use incognito so your own ad blocker and logged-in state do not interfere with the test.
- In Google Analytics, go to Reports → Realtime.
- You should see at least one active user — you. If the number is 0, the tracking code is not firing.

If nothing shows up, check these common culprits:
- Cache: clear your site cache and browser cache, then check again. Caching plugins can serve an old page version without the tracking code.
- Wrong property: make sure the Measurement ID on your site matches the property you are viewing. A single wrong character sends the data to a property you never look at.
- Ad blockers: they can block Google Analytics — disable yours while testing, and remember that some of your real visitors use them too, so your numbers will always undercount slightly.
- Consent banners: if you use a cookie consent plugin, analytics stays blocked until visitors accept cookies. That is correct behaviour, not a bug — but it means your early numbers will look low until you check the consent rate.
- Two methods at once: if you installed Site Kit and also pasted the snippet, remove one. Double tracking inflates every number and makes the data useless.
Give the Realtime check a full minute. GA4 sometimes takes 30–60 seconds to show a new visitor, and refreshing too quickly makes a working setup look broken. If you see yourself in Realtime, the installation is done — everything from here is reading the data.
What to Look at First in Your Dashboard
GA4 can feel overwhelming. Ignore 90% of it for now and focus on these four reports. Check them once a week and you will understand your site better than most owners do after a year.
Traffic Acquisition — Where visitors come from
Reports → Acquisition → Traffic acquisition shows whether visitors arrive via organic search, social media, direct visits, or referrals. Growing organic search numbers mean your SEO is working. If one channel dominates, that tells you where to invest: a site getting 80% of traffic from Pinterest needs a different content plan than one getting 80% from Google.
Pages and Screens — Which content wins
Reports → Engagement → Pages and screens lists your most-viewed pages. Double down on topics that perform and improve the ones that do not. A post ranking tenth in views but first in time-on-page is a candidate for an update and a better internal link or two — small fixes that often lift it into the top five.
Demographics — Who your audience is
Reports → User → Demographics shows readers’ countries, cities, and devices. If 80% of your audience is on mobile, your site must look great on phones. If most readers are in the US and UK, publish on their schedule, not yours.
Realtime — What is happening right now
Perfect after publishing a new post: share it on social media and watch visitors arrive live. It is also the fastest way to confirm a new page is being tracked at all — publish, visit in incognito, and check Realtime within a minute.
Common Mistakes to Avoid
- Installing two tracking methods at once: Site Kit plus a manual snippet double-counts every visitor. Pick one method and stick with it.
- Forgetting to exclude your own visits: go to Admin → Data Filters and set up an internal traffic filter for your IP, or your own browsing inflates the numbers. On a small site, your own visits can be a visible share of the total.
- Panicking over day-one numbers: data starts from zero the moment you install tracking. Give it 2–4 weeks before drawing conclusions. A single day tells you almost nothing; a month tells you a lot.
- Ignoring privacy rules: if you have EU or UK visitors, add a cookie consent banner and a privacy policy that mentions Google Analytics. The rules are not optional, and the fines are real.
- Never looking at the data: the most common mistake of all. Set a weekly 10-minute reminder to check your key reports. Analytics only helps if you actually open it.
- Comparing GA4 numbers with old Universal Analytics numbers: the two systems count sessions and users differently, so a drop after the switch usually means a different counting method, not a real traffic loss.
Security matters here too: the Google account that owns your Analytics property is the same account that can grant access to others, so protect it with two-factor authentication and review who has access every few months. Our guide on how to secure a WordPress website from hackers covers the WordPress side of that same habit, and keeping your PHP current — see how to update the PHP version in WordPress — keeps the whole stack, including your tracking plugins, running safely.
Adding Google Analytics to WordPress comes down to three steps: create your free GA4 property and grab your Measurement ID, install it via a plugin like Site Kit by Google (or paste the code manually with WPCode), and verify tracking with the Realtime report. About 15 minutes of work — and every site decision you make afterward gets smarter.
Your next moves: check Realtime after your next post, set up an internal traffic filter so your own visits do not skew the data, and give it a month before judging your numbers.
Frequently Asked Questions
Is Google Analytics free for WordPress?
Yes, completely free — both the analytics service and connecting it to WordPress, whether by plugin or manually. There is a paid enterprise tier (Analytics 360), but no small or medium website needs it.
Will Google Analytics slow down my site?
Barely. The script is small and loads asynchronously, so it does not block your page from rendering. Heavy images and bloated themes are the real speed killers — optimise those first before worrying about the analytics script.
Can I add Google Analytics to WordPress.com?
Only on paid plans — the free WordPress.com plan blocks third-party tracking code. If you are on a free plan, consider self-hosted WordPress instead, where you control every plugin and code snippet.
How long until I see data?
Realtime data appears within seconds once tracking works. Standard reports populate within 24–48 hours, and meaningful trends need 2–4 weeks of data. Be patient — analytics rewards consistency.
Do I need Google Analytics if I use Jetpack Stats?
Jetpack Stats is fine for a quick traffic glance, but Google Analytics goes deeper: traffic sources, demographics, conversion tracking, and integration with Google Ads and Search Console. Most serious sites run both — Jetpack for the quick check, GA4 for the real analysis.

