How to Add Google Analytics to WordPress and Understand Your Traffic
Google Analytics is the most widely used website analytics tool, and for good reason, it’s free, powerful, and gives you detailed insights into who visits your site, where they come from, and what they do once they arrive. If you’re running a WordPress site without analytics, you’re essentially flying blind.
This beginner-friendly guide walks you through setting up Google Analytics 4 (GA4) on your WordPress site, understanding the key metrics that matter, and using the data to make smarter decisions about your content and marketing.
What Is Google Analytics 4 (GA4)?
Google Analytics 4 is the current version of Google’s analytics platform, replacing the older Universal Analytics. GA4 uses an event-based tracking model instead of session-based tracking, which means it captures more detailed information about how users interact with your site.
Key differences from the old Universal Analytics:
- Event-based tracking, Every interaction (page view, scroll, click, video play) is tracked as an event
- Cross-platform tracking, Track users across your website and mobile app in one place
- Privacy-focused, Built with cookie-less measurement capabilities for a privacy-first web
- AI-powered insights, Automatic anomaly detection and predictive metrics
Step 1: Create a Google Analytics Account
- Go to analytics.google.com and sign in with your Google account.
- Click Start measuring (new account) or Admin > Create Account (existing account).
- Enter your account name (e.g., your business name).
- Create a property, enter your website name, select your time zone and currency.
- Choose your business size and objectives (this customizes your default reports).
- Accept the terms of service.
- Select Web as your platform and enter your website URL.
- Click Create Stream.
You’ll now see your Measurement ID (starts with G-). Copy this, you’ll need it in the next step.
Step 2: Add Google Analytics to WordPress
There are three methods to connect GA4 to WordPress. Choose the one that matches your comfort level.
Method 1: Google Site Kit Plugin (Recommended for Beginners)
Site Kit by Google is the official Google plugin for WordPress. It connects Analytics, Search Console, AdSense, and PageSpeed Insights in one dashboard.
- Go to Plugins > Add New and search for “Site Kit by Google”.
- Install and activate the plugin.
- Click Start Setup and sign in with your Google account.
- Grant the requested permissions.
- Site Kit will automatically detect your GA4 property or let you select one.
- Complete the setup wizard.
Site Kit adds the tracking code automatically and shows a simplified analytics dashboard right inside your WordPress admin. No code editing required.
Method 2: MonsterInsights Plugin
MonsterInsights is the most popular third-party analytics plugin for WordPress. It offers more detailed WordPress-specific reports than Site Kit.
- Install and activate MonsterInsights from Plugins > Add New.
- Go to Insights > Settings.
- Click Connect MonsterInsights and authenticate with your Google account.
- Select your GA4 property.
- Complete the setup wizard.
MonsterInsights’ free version covers basic tracking. The Pro version adds e-commerce tracking, form tracking, custom dimensions, and real-time stats.
Method 3: Manual Tracking Code (For Developers)
If you prefer not to use a plugin, you can add the GA4 tracking code directly to your theme:
- In your GA4 property, go to Admin > Data Streams > Web and click your stream.
- Under Tagging Instructions, select Install manually.
- Copy the Global Site Tag (gtag.js) code snippet.
- In WordPress, go to Appearance > Theme File Editor (or edit your child theme’s
header.php). - Paste the code just before the closing
</head>tag. - Save the file.
Important: If you use a block theme, add the tracking code via a custom plugin or the wp_head action hook instead of editing theme files directly:
add_action( 'wp_head', function() {
?>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
<?php
} );
Replace G-XXXXXXXXXX with your actual Measurement ID.
Step 3: Verify Tracking Is Working
After adding the tracking code, verify it’s collecting data:
- Go to your GA4 property and click Reports > Realtime.
- Open your website in a new browser tab.
- Within 30 seconds, you should see yourself as an active user in the Realtime report.
- Navigate to a few pages and check that page views appear in real-time.
If you don’t see data, check that ad blockers are disabled, the tracking code is on all pages, and there are no JavaScript errors in the browser console.
Understanding Your GA4 Dashboard
GA4’s interface can feel overwhelming at first. Here are the key reports that matter most for WordPress site owners:
Home (Overview)
Shows a snapshot of users, sessions, and key events over the last 7 days. The AI insights card highlights unusual traffic patterns automatically.
Acquisition > Traffic Acquisition
This answers “where do my visitors come from?” You’ll see traffic broken down by channel: Organic Search (Google), Direct (typed URL), Social (Facebook, Twitter), Referral (links from other sites), and Paid Search (Google Ads).
Engagement > Pages and Screens
Shows your most visited pages, average engagement time per page, and event counts. Use this to find your top-performing content and identify pages where visitors leave quickly.
Demographics > Overview
See where your visitors are located (country, city), their age range, gender, and interests. Useful for understanding if you’re reaching your target audience.
Key Metrics Every Beginner Should Track
- Users, How many unique people visited your site in a given period
- Sessions, Total number of visits (one user can have multiple sessions)
- Engagement rate, Percentage of sessions where users actively interacted (scrolled, clicked, stayed 10+ seconds). This replaced the old “bounce rate” metric
- Average engagement time, How long users actively spend on your site per session
- Views (page views), Total pages viewed across all sessions
- Conversions, Specific actions you define as valuable (newsletter signup, contact form submission, purchase)
Privacy and GDPR Considerations
If your site has visitors from the EU, UK, or other privacy-regulated regions, you need to handle analytics consent properly:
- Add a cookie consent banner that specifically mentions analytics tracking. Plugins like Complianz or CookieYes integrate with GA4.
- Enable IP anonymization, GA4 does this by default, unlike Universal Analytics which required manual configuration.
- Configure data retention in GA4: go to Admin > Data Settings > Data Retention and set it to the minimum period you need (2 or 14 months).
- Disable advertising features if you don’t use them, under Admin > Data Settings > Data Collection.
Frequently Asked Questions
Is Google Analytics free?
Yes. Google Analytics 4 is completely free for websites of all sizes. Google Analytics 360 is the paid enterprise version, but most WordPress sites will never need it.
Will Google Analytics slow down my site?
The GA4 tracking script adds about 20-30KB to your page load. On modern connections, this is negligible. If you’re concerned about performance, load the script asynchronously (which the default code already does) or use Google Tag Manager with delayed loading.
Should I use a plugin or add the code manually?
For beginners, use Site Kit or MonsterInsights, they handle the technical setup and give you in-dashboard reporting. If you’re comfortable with code and want minimal overhead, the manual method works well.
How long does it take to see data?
Real-time data appears within seconds. Full reports typically populate within 24-48 hours after initial setup. Historical data is not retroactive, tracking only starts from the moment the code is installed.