How to Install Google Analytics in WordPress (3 Easy Methods)
By wpmew
To install Google Analytics in WordPress, create a Google Analytics 4 (GA4) property, then connect it to your site with Site Kit by Google, an analytics plugin such as MonsterInsights, or by pasting the Google tag into your theme’s header. Site Kit is the easiest free method for most beginners.
Short answer: Use Site Kit if you want a free, official setup in about five minutes. Paste the tag manually only if you’re comfortable editing theme code and want zero extra plugins.
Key takeaways
- Google Analytics 4 is the only version of Google Analytics now. Universal Analytics stopped collecting data in 2023.
- Use only one method. Adding the tag twice counts every visit twice.
- Check that it works with GA4’s Realtime report or Tag Assistant before trusting the numbers.
- If you have EU or UK visitors, you need a cookie consent banner before loading analytics.
[IMAGE: Screenshot of the GA4 Realtime report showing active users. Suggested alt: “Google Analytics 4 realtime report in WordPress”. Suggested filename: ga4-realtime-report.webp.]
Step 1: Create a Google Analytics 4 property
Do this first, whichever method you choose.
- Go to analytics.google.com and sign in with your Google account.
- Click Start measuring (or Admin → Create → Property if you already have an account).
- Enter an account name, such as your business name.
- Enter a property name, reporting time zone, and currency.
- Choose your business details and objectives, then accept the terms.
- Choose Web as the platform, enter your website URL and a stream name, and click Create stream.
You’ll see a Measurement ID that starts with G-. Keep this tab open, because you may need it in Method 2 or 3.
Tip: Leave Enhanced measurement turned on. It tracks scrolls, outbound clicks, site search, file downloads, and video views without any extra setup.
Method 1: Site Kit by Google (recommended for beginners)
Site Kit is Google’s official WordPress plugin. It connects Analytics, Search Console, and PageSpeed Insights in one place.
- In WordPress, go to Plugins → Add New, search for Site Kit by Google, then install and activate it.
- Click Start setup and sign in with the same Google account you used for Analytics.
- Allow the requested permissions and verify site ownership. Site Kit does this for you.
- When asked, turn on Google Analytics and choose the account, property, and web stream you created.
- Finish setup. Site Kit adds the Google tag to every page automatically.
Pros: Free, official, no code, and adds Search Console data to your dashboard. Cons: Its dashboard reports are basic. You’ll still use analytics.google.com for detailed reports.
Method 2: MonsterInsights or another analytics plugin
MonsterInsights, ExactMetrics, and similar plugins add GA4 and show easy-to-read reports inside WordPress. Their paid plans add eCommerce tracking, form conversion tracking, and author reports without editing GA4 settings.
- Install and activate MonsterInsights from Plugins → Add New.
- Run the setup wizard and click Connect MonsterInsights.
- Sign in to Google and choose your GA4 property.
- Finish the wizard with the recommended settings.
Pros: Beginner-friendly reports, one-click WooCommerce tracking on paid plans. Cons: Advanced features need a paid license. It’s another plugin to maintain.
Method 3: Add the Google tag manually
This method adds no plugin, but theme updates can remove your code unless you use a child theme or a snippets plugin.
- In GA4, go to Admin → Data streams, open your web stream, and click View tag instructions → Install manually.
- Copy the full Google tag. It starts with
<!-- Google tag (gtag.js) -->. - Add it to the
<head>of your site using one of these options:- A header/footer code plugin such as WPCode: paste the tag into the Header box and save.
- A child theme’s
functions.php, using thewp_headhook.
Example for a child theme (replace G-XXXXXXXXXX with your Measurement ID):
add_action( 'wp_head', function () {
if ( is_user_logged_in() ) {
return; // Don't track your own visits.
}
?>
<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
} );
Pros: Lightweight, full control. Cons: Easy to break, and there are no reports inside WordPress.
Which method should you choose?
| Your situation | Best method |
|---|---|
| New site, want free and simple | Site Kit by Google |
| Online store, want reports in WordPress | MonsterInsights (paid) |
| Developer, want no extra plugins | Manual tag |
| Already use Google Tag Manager | Add a GA4 tag inside GTM, not in WordPress |
How to check Google Analytics is working
- Open your website in a private or incognito window. Logged-in admins are often excluded from tracking.
- In GA4, go to Reports → Realtime.
- You should see at least one active user within a minute.
You can also use Tag Assistant (tagassistant.google.com) to confirm the tag fires only once per page.
Data not showing? Standard reports can take 24–48 hours to fill in. Realtime should work right away.
Common mistakes to avoid
- Double tracking. You installed Site Kit and also pasted the tag manually, or your theme has an analytics field. Look for two
gtag/jsrequests in your browser’s Network tab. - Caching the old version. Clear your caching plugin and CDN cache after adding the tag.
- Tracking your own visits. Exclude logged-in users, or add an internal traffic filter in GA4 under Admin → Data streams → Configure tag settings → Define internal traffic.
- Not linking Search Console. In GA4, go to Admin → Product links → Search Console links to see the search queries that bring visitors.
- Skipping consent. Use a consent plugin that supports Google Consent Mode v2 if you have visitors from the EU or UK.
What to track after setup
- Key events (conversions): mark form submissions, purchases, or sign-ups as key events in Admin → Events.
- Traffic sources: Reports → Acquisition → Traffic acquisition.
- Top pages: Reports → Engagement → Pages and screens.
- Site search terms: available if Enhanced measurement is on.
FAQs
Is Google Analytics free for WordPress?
Yes. Google Analytics 4 is free for almost all websites. Site Kit is also free. Some analytics plugins charge for advanced reports.
Does Google Analytics slow down WordPress?
The Google tag loads asynchronously, so its effect is small. Loading it twice, or loading many other marketing tags, has a bigger effect on speed.
Can I use Google Analytics without a plugin?
Yes. Use Method 3 to paste the Google tag into your site’s header through a child theme or your theme’s custom code setting.
What’s the difference between Google Analytics and Search Console?
Analytics shows what visitors do on your site. Search Console shows how your site performs in Google Search: impressions, clicks, queries, and indexing problems. Use both.