Google Analytics 4 (GA4) is the current version of Google Analytics. This guide covers three ways to connect it to your WordPress site — pick the method that fits your setup.
Before you start: create a GA4 property
- Go to analytics.google.com and sign in with your Google account.
- Click Admin (gear icon, bottom-left).
- Click + Create → Property.
- Follow the wizard: name your property, choose your industry, and click Create.
- Under “Data collection,” choose Web and enter your site URL.
- Copy your Measurement ID — it looks like
G-XXXXXXXXXX.
Method 1 — Site Kit by Google (Recommended)
Site Kit is Google’s official WordPress plugin. It connects GA4, Search Console, PageSpeed, and AdSense in one place.
- Go to Plugins → Add New, search for Site Kit by Google, and install it.
- Click Start Setup and sign in with your Google account.
- Grant the requested permissions.
- Connect your Google Analytics property and click Configure Analytics.
Site Kit injects the GA4 tag automatically — no code needed.
Method 2 — Insert Headers and Footers plugin
If you prefer not to use Site Kit:
- Copy the GA4 tracking snippet from Google Analytics (Admin → Data Streams → your stream → “View tag instructions”).
- Install the Insert Headers and Footers plugin.
- Go to Settings → Insert Headers and Footers.
- Paste the GA4 snippet into the Scripts in Header box.
- Click Save.
Method 3 — Add to child theme directly
For developers who want zero plugin overhead, add the snippet to your child theme’s functions.php:
add_action('wp_head', function() {
if (is_admin()) return;
?>
<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
}, 1);
Replace G-XXXXXXXXXX with your actual Measurement ID.
Verifying the connection
Go to Google Analytics → Reports → Realtime. Open your site in another tab and navigate around. You should see yourself appear as an active user within 30 seconds.
Key reports to monitor
- Acquisition → Traffic acquisition — where your visitors come from (organic, social, direct, referral)
- Engagement → Pages and screens — which pages get the most views and longest engagement
- Engagement → Events — button clicks, form submissions, scroll depth (GA4 tracks these automatically)
- Monetization → Ecommerce purchases — revenue data (requires WooCommerce GA4 integration)
GDPR and cookie consent
Under GDPR, you must obtain consent before loading tracking scripts for EU visitors. If you have EU users, use a cookie consent plugin (Cookiebot, Real Cookie Banner, or Complianz) that blocks GA4 until consent is given. Site Kit has built-in integration with several consent plugins.