How to Install Google Analytics for WordPress
Getting your website online is a huge first step, but the real work starts when you try to understand who’s visiting and what they're doing. Google Analytics is the best free tool for seeing exactly how people find and interact with your WordPress site. This guide will walk you through, step-by-step, the most popular and effective methods to get it installed.
Why Every WordPress Site Needs Google Analytics
Before jumping into the setup, it’s worth quickly covering why this is so important. Without analytics, you're essentially flying blind. You might be creating content, running ads, or promoting on social media, but you have no real way to measure what’s working.
Google Analytics answers fundamental questions that help you grow your business:
- Who are my visitors? Understand user demographics like their age, gender, and location.
- How do they find me? See which channels drive the most traffic - like organic search (Google), social media (Facebook, Instagram), or referrals from other websites.
- What content is most popular? Identify your best-performing blog posts and pages so you can create more of what your audience loves.
- Are my marketing efforts paying off? Track conversions, like form submissions or product sales, to understand your return on investment.
In short, it turns guesswork into an informed strategy, allowing you to make better decisions backed by real user data.
Before You Start: Creating a Google Analytics 4 Property
Regardless of which installation method you choose, you first need a Google Analytics account and what's called a "GA4 Property." If you already have one, you can skip to the next section. If you're new to this, follow these simple steps.
- Go to the Google Analytics website and click "Start for free." You'll need to sign in with your Google account.
- Once inside, click the "Admin" gear icon at the bottom-left if you aren't already in the setup screen. Then, click on "Create Account."
- Account Setup: Give your account a name. This is usually your business or company name. It acts as a top-level container. Click "Next."
- Property Creation: Name your property. It's best practice to use your website's name or URL here, like "mycoolwebsite.com." Select your reporting time zone and currency. Click "Next."
- Business Details: Provide some basic information about your industry and business size. Google uses this to give you better reporting benchmarks. Click "Create" and accept the terms of service.
- Set up a Data Stream: This is the final and most important step. A "Data Stream" is just a source of data for your property, which in this case is your website. Choose "Web" as your platform.
- Enter Your Website Details: Type in your website's URL (e.g., www.mycoolwebsite.com) and give the stream a name (it can just be your website's name again). Click "Create stream."
- Find Your Tracking ID and Code: After creating the stream, you'll land on a page with all the details you need. The two key pieces of information are:
- Measurement ID: A unique identifier that starts with "G-" (e.g., G-XYZ123ABC).
- Global Site Tag (gtag.js): A snippet of JavaScript code. You can find this by clicking "View tag instructions" and then selecting the "Install manually" tab.
Keep this page open in a browser tab. You'll need one or both of these pieces for the methods below.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Method 1: Using a WordPress Plugin (The Easy Way)
For most WordPress users, a plugin is the simplest and safest way to add Google Analytics. You won't have to touch any code, the risk of error is low, and many plugins offer extra features, like showing you simplified reports right inside your WordPress dashboard.
Our top recommendation for beginners is the official Site Kit by Google plugin. It’s free, maintained by Google, and seamlessly connects several Google services (Analytics, Search Console, AdSense) to your site.
How to Install with Site Kit by Google
- In your WordPress dashboard, navigate to Plugins > Add New.
- In the search bar, type "Site Kit by Google."
- Find the plugin in the search results and click "Install Now," then "Activate."
- After activation, you'll see a banner prompting you to start the setup. Click the "Start Setup" button.
- Follow the on-screen instructions. Site Kit will guide you through connecting your Google account. You’ll need to grant it permission to access your Google Analytics data. Be sure to select the same Google account you used to create your analytics property.
- Site Kit will automatically detect your new GA4 property. Simply confirm that it's the right one, and the plugin will handle the rest. It places all the necessary code on your site for you.
That’s it! You're done. Site Kit will start populating your WordPress dashboard with data from Google Analytics within a day or two.
Method 2: Manually Adding the Tracking Code (For minimalists)
If you prefer to keep the number of plugins on your site to a minimum, you can add the tracking code directly to your theme's files. It’s a bit more technical, but completely manageable if you follow the steps carefully.
A quick but important warning: Editing theme files directly can break your site if you make a mistake. It is highly recommended to use a Child Theme for this. If you add the code to your parent theme's files, it will be wiped out the next time your theme updates.
Steps to Add the Code Manually
- Go back to your Google Analytics Data Stream tab and copy the entire Global Site Tag (gtag.js) snippet.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XYZ123ABC"></script>
<script>
window.dataLayer = window.dataLayer || [],
function gtag(){dataLayer.push(arguments),}
gtag('js', new Date()),
gtag('config', 'G-XYZ123ABC'),
</script>- In your WordPress dashboard, go to Appearance > Theme File Editor.
- On the right-hand sidebar, find and click on the file named Header (header.php). Make sure you are editing your child theme's file.
- Scroll down until you find the closing
</head>tag. - Paste your Global Site Tag code on a new line just before the closing
</head>tag. - Click "Update File" to save your changes.
Your Google Analytics tracking code is now active across every page of your website.
Method 3: Using Google Tag Manager (The Advanced & Scalable Way)
Google Tag Manager (GTM) is a free tool that acts as a container for all your website’s tracking codes (or "tags"). This is the preferred method for marketers, agencies, and businesses that plan to use multiple tracking scripts, like a Facebook Pixel, LinkedIn Insight Tag, and so on.
The main benefit is that once you install the GTM container, you can add, remove, and manage all your tags from the GTM interface without ever needing to touch your website’s code again.
This method has two main parts:
- Add the Google Tag Manager script to your WordPress site.
- Add your Google Analytics tag inside Google Tag Manager.
The easiest way to add the GTM script itself is with a lightweight plugin like "GTM4WP" or by manually pasting the container snippet into your header and body files (similar to Method 2). Once the container is installed on your site, you just log into GTM, create a new "GA4 Configuration" tag, paste in your Measurement ID, set the trigger to "All Pages," and publish. It provides the most flexibility for future growth but has a slightly steeper learning curve.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
How to Verify Your Google Analytics Installation
After you’ve added the tracking code using one of the methods above, you’ll want to confirm it’s actually working. The easiest way to do this is with the "Realtime" report in Google Analytics.
- Log into your Google Analytics account.
- In the left-hand navigation, go to Reports > Realtime.
- In a separate browser tab or an incognito window, open your website.
- Go back to the Realtime report in Google Analytics. Within a minute or two, you should see the number in the "Users in last 30 minutes" card jump to 1 (or more).
If you see your activity show up, congratulations! You have successfully installed Google Analytics on your WordPress website. Keep in mind that regular reports can take 24-48 hours to fully populate with data.
Final Thoughts
Setting up Google Analytics is a foundational step in building a data-driven strategy for your website. Now that tracking is in place, you can finally see exactly where your traffic comes from, what content performs best, and how users behave as they move through your Pages. This information is your roadmap for making smarter decisions to grow your audience and your business.
Once you start collecting all that great data in Google Analytics, you’ll find the next challenge is quickly making sense of it all. Manually building reports to answer specific business questions can feel complex and slow. That's exactly why we built Graphed. We let you connect your Google Analytics account in seconds and then use simple, natural language to create dashboards and reports. Instead of clicking through menus, you can just ask, "Show me my top 10 landing pages from Google Search this month," and get a live, automated dashboard instantly.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.