How to Add Google Analytics to WordPress (Step-by-Step for Beginners)
You’ve built your WordPress site, published some posts, and now you’re wondering — is anyone actually visiting? Google Analytics answers that question. It shows you exactly how many people visit your site, where they come from, which pages they read, and how long they stay.
Setting it up is easier than most people think, and it’s completely free. This guide covers two methods — with a plugin and without one.
What Is Google Analytics and Why Do You Need It?
Google Analytics is a free tool by Google that tracks your website traffic in detail. Without it, you’re essentially flying blind — you have no idea which blog posts are working, where your visitors are coming from, or which pages are losing people.
For a professional WordPress site, especially one trying to attract clients or rank on Google, Analytics is non-negotiable. If you haven’t set up your SEO foundation yet, read my guide on WordPress SEO for beginners first — Analytics and SEO work hand in hand.
Step 1: Create a Google Analytics Account
Go to analytics.google.com and sign in with your Google account.
Click Start measuring → enter your account name → click Next → enter your property name (usually your site name) → select your country and timezone → click Next → choose Web as your platform → enter your website URL → click Create stream.
You’ll now see your Measurement ID — it looks like G-XXXXXXXXXX. Keep this tab open, you’ll need this in a moment.
Method 1: Using a Plugin (Recommended for Beginners)
This is the easiest method. I recommend Site Kit by Google — it’s Google’s own official plugin.
Step 1: Go to WordPress Dashboard → Plugins → Add New → search “Site Kit by Google” → Install → Activate.
Step 2: Click Start Setup → Sign in with your Google account → Grant permissions → Select your Analytics property → click Configure Analytics.
That’s it. Site Kit connects everything automatically — no copy-pasting of code needed.
The advantage of Site Kit is that it also connects Google Search Console in the same place, giving you a complete picture of your site’s performance inside your WordPress dashboard. This pairs perfectly with the essential security practices and speed optimization you should already have in place — because Analytics will quickly show you if a slow page is losing visitors.
Method 2: Adding the Code Manually (No Plugin)
If you prefer not to add another plugin, you can paste the Analytics code directly into your theme. This is the lighter, faster option.
Step 1: In your Google Analytics account, go to Admin → Data Streams → your site → View tag instructions → Install manually.
Copy the full <script> tag shown there.
Step 2: In WordPress, go to Appearance → Theme File Editor → open header.php → paste the code just before the closing </head> tag → click Update File.
Important: Always do this in a child theme, not the parent theme — otherwise your code disappears after every theme update. If you haven’t set up a child theme yet, read my guide on how to create a WordPress child theme before doing this step.
How to Verify It’s Working
After setting up either method, go back to Google Analytics → click Reports → Realtime. Open your website in a new tab. You should see “1 active user” appear in the Realtime report within a minute or two. If it shows up — you’re connected.
What to Track as a Beginner
Once Analytics is running, focus on these four reports first:
Acquisition — shows where your visitors come from (Google, social media, direct). Pages and Screens — shows which pages get the most views. Engagement — shows how long people stay and how many pages they visit per session. Demographics — shows which countries your visitors are from.
Check these once a week. After a month you’ll start seeing patterns — which posts bring the most traffic, which pages people leave quickly, and which traffic sources are growing.
One Important Setting — Exclude Your Own Visits
By default, Analytics counts every time you visit your own site. This inflates your numbers. To exclude yourself, install the Google Analytics Opt-Out browser extension on any browser you use to log into your site.
Setting up Google Analytics is one of those things that takes 10 minutes but pays off for years. The data you collect today will guide every content and SEO decision you make going forward — including decisions on which hosting to use when you’re ready to scale.