How do I install Google Analytics on my WordPress site?
Applies to: WordPress.org (self-hosted)
Last updated: May 2025
Problem
You want to track how people find and use your website—page views, visitor behavior, traffic sources—but you’re not sure how to set up Google Analytics with WordPress.
Solution
You can install Google Analytics in WordPress by either manually adding the tracking code or using a plugin for easier integration and dashboard access.
Step 1: Set Up Google Analytics
- Go to https://analytics.google.com
- Sign in with your Google account
- Click Admin > Create Account
- Enter your account name, property name (your website), and URL
- Choose the Web platform
- You’ll receive a Measurement ID (e.g.,
G-XXXXXXXXXX) for Google Analytics 4 (GA4)
Option 1: Use a Plugin (Recommended for Most Users)
A. Use Site Kit by Google
- Go to Plugins > Add New
- Search for Site Kit by Google
- Click Install Now, then Activate
- Click Start Setup and follow the on-screen steps:
- Sign in with your Google account
- Grant permissions
- Choose the site profile from your Google Analytics account
Site Kit will:
- Automatically insert the tracking code
- Show analytics data inside your WordPress dashboard
B. Other Plugins You Can Use
- MonsterInsights (Lite) – User-friendly with analytics dashboard
- GA Google Analytics – Lightweight plugin for adding tracking code
Option 2: Add Tracking Code Manually (Advanced)
- Copy your GA4 Measurement ID or the tracking snippet
- In your WordPress dashboard:
- Go to Appearance > Theme File Editor
- Open
header.php(preferably in a child theme) - Paste the code just before the closing
</head>tag
- Click Update File
Important: Always back up your site before editing theme files.
Verify That It’s Working
- Visit your site in a new tab
- Go to your Google Analytics account
- Navigate to Reports > Realtime
- You should see at least 1 active user (yourself)
Notes
- Google Analytics may take up to 24 hours to show full data
- Use Google Tag Manager for more complex setups (event tracking, multiple tags)
- Combine Google Analytics with Google Search Console (via Site Kit) for SEO insights




