themezinho
Performance

Connecting Google Analytics to your site

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

  1. Go to analytics.google.com and sign in with your Google account.
  2. Click Admin (gear icon, bottom-left).
  3. Click + Create → Property.
  4. Follow the wizard: name your property, choose your industry, and click Create.
  5. Under “Data collection,” choose Web and enter your site URL.
  6. 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.

  1. Go to Plugins → Add New, search for Site Kit by Google, and install it.
  2. Click Start Setup and sign in with your Google account.
  3. Grant the requested permissions.
  4. 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:

  1. Copy the GA4 tracking snippet from Google Analytics (Admin → Data Streams → your stream → “View tag instructions”).
  2. Install the Insert Headers and Footers plugin.
  3. Go to Settings → Insert Headers and Footers.
  4. Paste the GA4 snippet into the Scripts in Header box.
  5. 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.

Exclude your own traffic.Install the Google Analytics Opt-out Add-on browser extension so your own visits aren’t counted in the data.

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.

Support
Support
Customer Support