How to Set Up Google Analytics with WordPress

Cody Schneider8 min read

Connecting Google Analytics to your WordPress site is a non-negotiable step toward understanding your audience and growing your traffic. This vital tool shows you who is visiting your site, how they found you, and what they care about most. This article will guide you through creating your Google Analytics 4 account and show you three simple methods to get it installed on your WordPress website.

Why You Need Google Analytics on Your WordPress Site

Setting up Google Analytics is like turning on the lights in a dark room. Without it, you’re just guessing. With it, you get clear answers to the most important questions about your website, such as:

  • Who are my visitors? Understand user demographics like age, gender, and location, providing a clear picture of your audience.
  • How do people find my site? See which channels drive the most traffic - whether it's organic search from Google, social media, email newsletters, or referrals from other sites. This tells you which marketing efforts are actually working.
  • What content is most popular? Identify your highest-performing pages and blog posts. Knowing what resonates allows you to create more of what your audience loves and double down on successful topics.
  • How do users navigate my site? Follow the user journey to see which pages they land on, where they go next, and where they leave. This can help you optimize your site's navigation and key conversion paths.

Simply put, Google Analytics transforms vague hunches into actionable data, allowing you to make smarter decisions to grow your website effectively.

Step-by-Step: Creating a Google Analytics 4 Account and Property

Before you can add Google Analytics to WordPress, you need an account and a property to collect your data. If you already have a Google Analytics 4 property, you can skip to the next section. Otherwise, follow these steps to get set up.

Step 1: Create or Sign In to Your Google Analytics Account

Head over to the Google Analytics website. You can either sign in with your existing Google account or create a new one. Click “Start measuring” to begin.

Step 2: Set Up an Account

The first screen will ask for an Account name. This is the top-level container for your properties. You can name it after your business or yourself. Under "Account Data Sharing Settings," you can review and choose your preferences, though the defaults are fine for most users. Click "Next."

Step 3: Create a Property

Next, you’ll create a property. A "property" represents your website or app.

  • Property name: Enter the name of your website (e.g., "My Awesome Blog").
  • Reporting time zone: Select your local time zone.
  • Currency: Choose your primary currency.

Click "Next" to continue.

Step 4: Provide Your Business Details

On the next screen, Google asks for some basic information about your business to tailor your experience. Select your industry category and business size. Click "Next."

Step 5: Choose Your Business Objectives

Here, you can select what you want to achieve with Google Analytics. This helps GA4 customize the reports it shows you. It's fine to select "Examine user behavior" for a general-purpose setup, or pick a few goals that align with your site's purpose, like "Generate leads." After selecting your objectives, click "Create."

Step 6: Set Up a Data Stream

A "data stream" is the source of your data. Since you're installing this on a WordPress website, you'll choose "Web."

Enter your website's URL (make sure to select https://) and give the stream a name (e.g., "Website Stream"). Make sure "Enhanced measurement" is turned on. This feature automatically tracks important actions like page views, scrolls, outbound clicks, and file downloads without any extra setup. Click "Create stream."

Step 7: Find Your Measurement ID and Tracking Code

Once you create the stream, a "Web stream details" page will appear. This page contains the critical information you need to connect your site. You will see a Measurement ID that looks like G-XXXXXXXXXX. For many plugin-based methods, this ID is all you'll need.

If you need the full tracking code script (for methods 2 and 3 below), scroll down to the "View tag instructions" section. Under the "Install manually" tab, you'll find the Global Site Tag (gtag.js) script. This is the piece of JavaScript that actually tracks your visitors.

Keep this tab open - you're now ready to connect GA4 to WordPress!

3 Simple Ways to Add Google Analytics to WordPress

There are several ways to install Google Analytics on your WordPress site. We'll cover three of the most popular methods, from the simplest plugin-based install to a more manual approach.

Method 1: Using the Site Kit by Google Plugin (Recommended for Beginners)

This is by far the easiest and most user-friendly method. Site Kit is the official WordPress plugin from Google. It not only connects Google Analytics but also integrates other Google services like Search Console and AdSense directly into your WordPress dashboard.

How to Set It Up:

  1. Log into your WordPress admin dashboard.
  2. Navigate to Plugins > Add New.
  3. In the search bar, type "Site Kit by Google" and press Enter.
  4. Find the plugin, click Install Now, and then Activate.
  5. Once activated, you'll see a banner to start the setup. Click Start Setup.
  6. You'll be guided through a simple OAuth flow to connect your Google account. Sign in with the same account you used to create your Analytics property.
  7. Grant Site Kit permission to access your Google account data.
  8. Site Kit will automatically detect the Analytics property you just created. Simply confirm it, and you're done!

With Site Kit, you'll get a simplified Analytics report right inside your WordPress dashboard, giving you a quick overview of your traffic without ever leaving your site.

Method 2: Using the WPCode Plugin to Add the Tracking Code

If you prefer a lightweight solution and don't need the dashboard widgets from Site Kit, using a general-purpose plugin like WPCode (formerly Insert Headers and Footers) is an excellent choice. This method lets you add the tracking code without ever touching your theme files.

How to Set It Up:

  1. First, copy the entire Global Site Tag (gtag.js) script from your Google Analytics data stream settings. It looks like this:
<!-- 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>
  1. In your WordPress dashboard, go to Plugins > Add New, search for "WPCode," and install and activate the plugin.
  2. Navigate to Code Snippets > Header & Footer.
  3. Paste your entire Global Site Tag script into the "Header" box.
  4. Click Save Changes.

This plugin will now automatically insert the GA4 tracking code into the <head> section of every page on your site, which is exactly where Google wants it.

Method 3: Adding the Tracking Code Directly to Your Theme Files (Advanced)

Warning: This method is for more advanced users. Editing your theme files directly can break your site if done incorrectly. Additionally, your tracking code may be erased if you update your theme. It is highly recommended to use a child theme for this method. Proceed with caution.

If you're comfortable editing code and don't want to install another plugin, you can add the GA4 tracking code directly into your theme's header.php file.

How to Set It Up:

  1. Copy your full Global Site Tag (gtag.js) script from your Google Analytics data stream.
  2. In your WordPress dashboard, go to Appearance > Theme File Editor.
  3. From the list of theme files on the right, click to open the Theme Header (header.php) file.
  4. Find the closing </head> tag. Paste your gtag.js code on the line right before it.
  5. Click the Update File button to save your changes.

How to Verify Google Analytics is Working

After installing your tracking code, it's essential to confirm that it's working properly. Don't just assume it’s collecting data! Here are two easy ways to check.

1. Use the Realtime Report

This is the simplest and most reliable method.

  1. Log in to your Google Analytics account.
  2. Navigate to Reports > Realtime.
  3. In a separate browser window (or in incognito mode), open your own website.
  4. Wait for a minute or two. You should see yourself appear as at least one active user in the Realtime report. If you see activity, congratulations - it works!

2. Use Your Browser's Developer Tools

For a more technical check, you can see if your browser is sending the tracking data.

  1. On your website, right-click and select "Inspect" to open the developer tools.
  2. Click on the "Network" tab.
  3. In the filter box, type collect.
  4. Refresh your webpage.
  5. You should see some entries appear with "google-analytics.com" or "analytics.google.com" in the name. This confirms that the tracking tag is firing and sending data to Google.

Final Thoughts

Connecting your WordPress site to Google Analytics is a foundational step that moves you from guesswork to data-driven growth. Whether you chose the simple path with the Site Kit plugin or added the code manually, you now have the tools to understand your site's performance and learn directly from your visitors' behavior.

Once your data starts flowing in, the next challenge is turning those numbers into clear, actionable insights without getting lost in complex reports. This is why we built Graphed. By connecting your Google Analytics account, you can skip the reports and just ask questions in plain English - like "what countries are driving the most traffic?" or "show me a bar chart of my most viewed pages last week" - and get instant dashboards and answers. It helps you get straight to the insights so you can spend less time analyzing and more time optimizing your site.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.