TutorialBeginner’s Guide

How to Install Google Analytics in WordPress for Beginners

Image placeholder
Share

You’ve built your WordPress website, picked a beautiful theme, and published your first posts. Now comes the big question: is anyone actually visiting? And if they are, who are they, how did they find you, and what do they do once they arrive?

That’s exactly what Google Analytics tells you. It’s free, it’s the most widely used analytics tool on the web, and connecting it to WordPress takes less than 15 minutes — even if you’ve never touched a line of code.

In this step-by-step guide, you’ll learn how to install Google Analytics in WordPress the right way. We’ll cover creating your Google Analytics 4 (GA4) account, three different installation methods (so you can pick the one that suits you), how to confirm tracking is working, and the beginner mistakes that quietly ruin your data.

What you’ll learn:

  • What Google Analytics 4 is and why your WordPress site needs it
  • How to create a Google Analytics account and get your Measurement ID
  • Method 1: Install Google Analytics with Site Kit by Google (recommended)
  • Method 2: Install Google Analytics with MonsterInsights
  • Method 3: Add Google Analytics manually with a code snippet (no plugin bloat)
  • How to verify Google Analytics is tracking correctly
  • Essential settings to configure after installation
  • Troubleshooting and frequently asked questions

What Is Google Analytics (and Why Is It GA4 Now)?

Google Analytics is a free web analytics service from Google that tracks and reports website traffic. Once installed, it records every visit to your site and turns that raw data into reports you can actually use.

The current version is Google Analytics 4 (GA4). The older version, Universal Analytics (tracking IDs that started with UA-), stopped processing data in July 2023 and was fully shut down in 2024. If you find an old tutorial telling you to paste a UA-XXXXXXX-X code, skip it — that code no longer does anything.

GA4 is built around events rather than page views alone. That means it automatically tracks things like scrolls, outbound link clicks, file downloads, site search, and video engagement without extra setup, thanks to a feature called Enhanced Measurement.

Why Your WordPress Site Needs Google Analytics

Here’s what Google Analytics helps you answer:

  • Who is visiting? See visitor countries, cities, languages, devices, and browsers.
  • How did they find you? Discover whether traffic comes from Google search, social media, email, or referral links.
  • What content works? Identify your most popular posts and pages so you can create more of what your audience wants.
  • Where do people leave? Spot pages with low engagement so you can improve them.
  • Are you reaching your goals? Track form submissions, purchases, sign-ups, and other conversions (called key events in GA4).

Without analytics, you’re making decisions based on guesswork. With it, every content, design, and marketing decision is backed by real data.


Before You Start: What You’ll Need

Make sure you have the following ready:

  1. A self-hosted WordPress.org website with administrator access. (On WordPress.com, adding analytics code or plugins requires a paid plan that supports plugins.)
  2. A Google account (a free Gmail account works perfectly).
  3. About 15 minutes.

Tip: Use a Google account that belongs to your business rather than a personal one if other people will manage the site. You can always add more users to Google Analytics later.


Step 1: Create Your Google Analytics 4 Account and Property

Regardless of which installation method you choose, you need a Google Analytics account first. (If you’re using Site Kit — Method 1 — you can also create the account from inside WordPress, but understanding these steps helps.)

1.1 Sign in to Google Analytics

Go to analytics.google.com and sign in with your Google account. Click Start measuring.

1.2 Set Up Your Account

  • Account name: Enter your business or website name (for example, “Unitedtheme”).
  • Account data-sharing settings: Review the checkboxes and choose what you’re comfortable sharing with Google. These are optional.

Click Next.

1.3 Create a Property

A property represents your website inside Google Analytics.

  • Property name: Your website name (e.g., “Unitedtheme Website”).
  • Reporting time zone: Choose your local time zone so daily reports line up with your day.
  • Currency: Select the currency you use, which matters if you run an online store.

Click Next.

1.4 Describe Your Business

Choose your industry category and business size, then select your business objectives (such as Generate leads, Drive online sales, or Understand web and/or app traffic). Google uses this to customize the default reports you see. Click Create and accept the Google Analytics Terms of Service.

1.5 Set Up a Web Data Stream

A data stream is the connection between your website and your GA4 property.

  1. Choose Web as your platform.
  2. Enter your website URL (e.g., unitedtheme.com) and make sure https:// is selected.
  3. Give the stream a name, such as “Unitedtheme Website.”
  4. Leave Enhanced measurement switched on — it automatically tracks scrolls, outbound clicks, site search, video engagement, and file downloads.
  5. Click Create stream.

1.6 Copy Your Measurement ID

You’ll now see your Web stream details page. In the top-right corner, you’ll find your Measurement ID, which looks like this:

G-XXXXXXXXXX

Copy it and keep this tab open — you’ll need it shortly.

Where to find it later: Go to Admin (gear icon) → Data collection and modification → Data streams, then click your web stream.


Choosing the Right Installation Method

There are several ways to add Google Analytics to WordPress. Here’s a quick comparison to help you decide:

Method Best for Difficulty Reports inside WordPress Extra plugin
Site Kit by Google Most beginners ⭐ Very easy Yes Yes (official Google plugin)
MonsterInsights Bloggers & WooCommerce stores wanting advanced tracking ⭐ Very easy Yes Yes
Manual code (WPCode) Performance-focused users who want minimal plugins ⭐⭐ Easy No Small snippet plugin
Theme files (functions.php) Developers ⭐⭐⭐ Moderate No None

Our recommendation: If you’re a beginner, start with Site Kit by Google. It’s free, built and maintained by Google, and connects Analytics, Search Console, and PageSpeed Insights in one place.

Important: Use only one method. Installing Google Analytics twice (for example, Site Kit and a manual snippet) double-counts your visitors and makes your data unreliable.


Site Kit is Google’s official WordPress plugin. It handles the tracking code for you and shows key stats right in your WordPress dashboard.

Step 1: Install and Activate Site Kit

  1. In your WordPress dashboard, go to Plugins → Add New Plugin.
  2. Search for “Site Kit by Google.”
  3. Click Install Now on the plugin by Google, then Activate.

Step 2: Start the Setup Wizard

After activation, you’ll see a banner prompting you to set up Site Kit. Click Start Setup.

Step 3: Sign in With Google

  1. Click Sign in with Google and choose the same Google account you used to create your Analytics property.
  2. Grant the requested permissions. Site Kit needs these to verify site ownership and read your data.
  3. Site Kit will automatically verify your site ownership and connect Google Search Console. Click Allow when prompted.

Step 4: Connect Google Analytics

  1. When asked, make sure the Analytics checkbox is ticked (it usually is by default).
  2. Site Kit will detect your existing Google Analytics account. Select:
    • Account: the account you created
    • Property: your GA4 property
    • Web data stream: the stream you set up in Step 1.5
  3. Click Configure Analytics.

Don’t have an Analytics account yet? Site Kit can create one for you right here — just choose “Set up a new account” and follow the prompts.

Step 5: Finish and Explore Your Dashboard

Click Go to my Dashboard. You’ll now find a Site Kit menu in your WordPress sidebar with traffic, top content, and search performance at a glance.

Data can take 24–48 hours to appear in the Site Kit dashboard, but real-time visits show up in Google Analytics within minutes (see the verification section below).

Go to Site Kit → Settings → Connected Services → Analytics → Edit and review:

  • Exclude from Analytics: Turn on exclusion for logged-in users (or at least administrators) so your own visits don’t skew your data.
  • Place Google Analytics code: Leave this enabled — it’s what actually adds the tracking tag to your site.

Method 2: Install Google Analytics with MonsterInsights

MonsterInsights is a popular Google Analytics plugin for WordPress. The free version (MonsterInsights Lite) covers the essentials, while paid plans add WooCommerce tracking, form conversions, author tracking, and more.

Step 1: Install MonsterInsights

  1. Go to Plugins → Add New Plugin.
  2. Search for “MonsterInsights.”
  3. Click Install Now, then Activate.

Step 2: Run the Setup Wizard

  1. The setup wizard launches automatically. (If it doesn’t, go to Insights → Settings and click Launch Setup Wizard.)
  2. Choose the category that best describes your site: Business website, Publisher (blog), or Ecommerce. Click Save and Continue.

Step 3: Connect Your Google Account

  1. Click Connect MonsterInsights.
  2. Sign in with your Google account and grant the requested permissions.
  3. Select your GA4 property from the dropdown and click Complete Connection.

MonsterInsights pre-configures sensible defaults such as file download tracking, affiliate link tracking, and excluding administrators from tracking. Review them, click Save and Continue, and finish the wizard.

You’ll now find reports under Insights → Reports in your WordPress dashboard.


Method 3: Add Google Analytics Manually with a Code Snippet (No Heavy Plugin)

If you want the lightest possible setup and don’t need reports inside WordPress, you can paste the Google tag directly onto your site. The safest way to do this is with a snippet plugin like WPCode, so your code survives theme updates.

Step 1: Get Your Google Tag Code

  1. In Google Analytics, go to Admin → Data collection and modification → Data streams and click your web stream.
  2. Click View tag instructions (under Google tag).
  3. Choose the Install manually tab.
  4. Copy the code. It looks like this (with your own Measurement ID instead of G-XXXXXXXXXX):

html

<!-- 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>

Step 2: Install WPCode

  1. Go to Plugins → Add New Plugin and search for “WPCode” (WPCode – Insert Headers and Footers + Custom Code Snippets).
  2. Click Install Now, then Activate.

Step 3: Paste the Code Into Your Site Header

  1. Go to Code Snippets → Header & Footer.
  2. Paste your Google tag into the Header box.
  3. Click Save Changes.

That’s it — the tag now loads on every page of your site.

Alternative: Add the Code via functions.php (For Developers)

If you’re comfortable editing theme files, you can add the tag through your child theme’s functions.php file. Never edit a parent theme directly — your changes will be wiped out on the next theme update.

php

/**
 * Add Google Analytics 4 tag to the site header.
 * Replace G-XXXXXXXXXX with your own Measurement ID.
 */
function unitedtheme_add_ga4_tag() {
    // Optional: don't track logged-in administrators.
    if ( current_user_can( 'manage_options' ) ) {
        return;
    }
    ?>
    <!-- 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
}
add_action( 'wp_head', 'unitedtheme_add_ga4_tag', 10 );

Caution: A typo in functions.php can take your site offline. Always back up your site first and, ideally, test on a staging site.

What About Google Tag Manager?

Google Tag Manager (GTM) is a free tool that lets you manage multiple tracking tags (Google Analytics, Meta Pixel, Google Ads, and more) from one dashboard without editing code each time. It’s powerful but adds a learning curve, so most beginners are better off with one of the three methods above. Once you’re comfortable, GTM is a great next step.


How to Verify Google Analytics Is Working

Don’t wait days to find out your tracking is broken. Check it right away using any of these methods.

Option 1: Use the Realtime Report

  1. Open your website in a new browser tab (use an incognito/private window, especially if you excluded logged-in admins).
  2. In Google Analytics, go to Reports → Realtime overview.
  3. Within a minute or so, you should see at least one active user — that’s you!

Option 2: Use Google Tag Assistant

  1. Visit tagassistant.google.com.
  2. Click Add domain, enter your website URL, and click Connect.
  3. Your site opens in a new tab. Back in Tag Assistant, you should see your Google tag (G-XXXXXXXXXX) listed as found and firing.

Option 3: Check Your Page Source

  1. Visit your site, right-click anywhere, and choose View Page Source.
  2. Press Ctrl + F (or Cmd + F on Mac) and search for your Measurement ID (G-).
  3. If you find it inside a gtag.js script, the tag is installed. If it appears twice, you have a duplicate installation to fix.

Note: Standard reports (outside Realtime) can take 24–48 hours to populate. Seeing your visit in Realtime is enough to confirm the installation works.


Essential Settings to Configure After Installing Google Analytics

Installation is only the beginning. These quick tweaks make your data far more accurate and useful.

1. Increase Data Retention

By default, GA4 keeps detailed user-level data for only 2 months, which limits the date range for custom reports (called Explorations). To extend it:

Admin → Data collection and modification → Data retention → set Event data retention to 14 months → Save.

2. Exclude Your Own Traffic

Your own visits can noticeably inflate numbers on a new site. Besides excluding logged-in users in your plugin, you can filter internal traffic by IP address:

  1. Go to Admin → Data streams → your stream → Configure tag settings → Show more → Define internal traffic.
  2. Click Create, name the rule, and enter your IP address.
  3. Then go to Admin → Data collection and modification → Data filters, open the Internal Traffic filter, and change its state from Testing to Active.

Linking Search Console shows which Google search queries bring visitors to your site — right inside Analytics. Site Kit does this automatically. Otherwise, go to Admin → Product links → Search Console links and follow the prompts.

4. Set Up Key Events (Conversions)

Mark the actions that matter to your business as key events — for example, contact form submissions, newsletter sign-ups, or purchases. Go to Admin → Data display → Events, find the event, and toggle Mark as key event.

If you have visitors from the EU, UK, or other regions with privacy laws (such as GDPR), you’ll typically need a cookie consent banner before analytics cookies load. Google also requires Consent Mode for sites that use its advertising features with visitors in the European Economic Area. Popular WordPress consent plugins like Complianz, CookieYes, and Cookiebot integrate with Google Consent Mode. Update your privacy policy to mention that you use Google Analytics.

This section is general guidance, not legal advice. Check the requirements that apply to your business and region.


Common Google Analytics Problems (and How to Fix Them)

“I don’t see any data in Google Analytics.” Wait at least 24–48 hours for standard reports. Check the Realtime report instead. Make sure you’re viewing the correct property, and confirm the tag appears in your page source.

“My traffic numbers suddenly doubled.” You probably have Google Analytics installed twice — for example, through your theme’s settings and a plugin. Search your page source for gtag and remove the duplicate.

“Realtime shows nothing when I visit my own site.” You may have excluded logged-in users or administrators. Visit your site in an incognito window. Ad blockers and privacy browser extensions can also block Google Analytics.

“My caching plugin seems to break tracking.” After installing Google Analytics, clear your caching plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache, etc.) and your CDN cache so visitors receive the updated page with the tracking code. If you use JavaScript delay or “load scripts on interaction” features, note that analytics will only fire after user interaction.

“I still have an old UA- tracking code.” Remove it. Universal Analytics is retired, and the old code adds unnecessary weight to your pages. Replace it with your GA4 G- tag.

“My theme has a field for a Google Analytics ID.” Some themes include an Analytics ID option. It works, but if you switch themes later, your tracking disappears. A plugin like Site Kit or WPCode keeps tracking independent of your theme.


Frequently Asked Questions

Is Google Analytics free for WordPress?

Yes. Google Analytics 4 is completely free for the vast majority of websites. There is a paid enterprise version (Google Analytics 360), but small and medium sites never need it. Site Kit and MonsterInsights Lite are also free.

Will Google Analytics slow down my WordPress site?

The Google tag loads asynchronously, so its impact on page speed is minimal. Using the manual method or Site Kit keeps things lean. If performance is a top priority, avoid stacking multiple analytics plugins.

Do I need a plugin to add Google Analytics to WordPress?

No. You can paste the tag into your child theme’s functions.php file or header. However, a plugin is safer for beginners because it won’t break when you update or change themes.

What’s the difference between a Measurement ID and a Tracking ID?

A Measurement ID (G-XXXXXXXXXX) belongs to Google Analytics 4. A Tracking ID (UA-XXXXXXX-X) belonged to the retired Universal Analytics. You only need the Measurement ID today.

How long does it take for Google Analytics to show data?

Realtime data appears within a minute or two. Standard reports usually take 24–48 hours to fully process.

Can I use Google Analytics with WooCommerce?

Yes. GA4 supports ecommerce tracking. Plugins such as Google for WooCommerce, MonsterInsights Pro, or a GTM-based setup send product views, add-to-carts, and purchases to Google Analytics.

Which is better: Site Kit or MonsterInsights?

For most beginners, Site Kit is the better starting point — it’s free, official, and also connects Search Console and PageSpeed Insights. MonsterInsights shines when you want advanced tracking (forms, ecommerce, authors) with friendly reports inside WordPress, especially on its paid plans.


Prefer watching to reading? These channels publish reliable, regularly updated walkthroughs on setting up Google Analytics 4 with WordPress:

Quick video searches:

Editor’s tip: To embed a video in WordPress, paste the YouTube video URL on its own line in the block editor — WordPress automatically converts it into an embedded player.


Conclusion

Installing Google Analytics in WordPress is one of the most valuable things you can do for your website. In just a few minutes, you’ve gone from guessing to knowing exactly who visits your site, how they found you, and what they do once they arrive.

Here’s a quick recap:

  1. Create a GA4 account, property, and web data stream, then copy your Measurement ID.
  2. Pick one installation method — Site Kit by Google (recommended for beginners), MonsterInsights, or a manual code snippet with WPCode.
  3. Verify tracking with the Realtime report or Google Tag Assistant.
  4. Fine-tune your settings — extend data retention, exclude your own traffic, link Search Console, and set up key events.

Give your data a few weeks to build up, then use it to guide your next blog post, design change, or marketing campaign. The more you understand your visitors, the better your WordPress site will perform.

Need a fast, SEO-optimized WordPress theme that works seamlessly with Google Analytics? Explore the theme collection at Unitedtheme.com and give your site the foundation it deserves.

How did you find this article?

Tap a reaction — it helps us write more of what you like.

Exclusive Avatar

Written by

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep reading

More from the journal