How to Install Google Analytics 4 on WordPress

Cody Schneider

Adding Google Analytics 4 to your WordPress site is a crucial first step toward understanding your website's visitors and performance. It gives you the raw data you need to learn who your audience is, where they come from, and what content they engage with most. This article will guide you through the three easiest ways to get GA4 installed on your WordPress site so you can start making data-informed decisions.

First, Create Your Google Analytics 4 Property

No matter which installation method you choose, you first need to create a Google Analytics 4 property. This is your account inside of Google's system where all your website data will live. If you're migrating from an older version (Universal Analytics), you'll still need to create a new, separate GA4 property.

Here's how to set it up:

  1. Navigate to the Google Analytics homepage and sign in with your Google account.

  2. Once logged in, click the gear icon for "Admin" in the bottom-left corner.

  3. In the "Property" column, click the blue "+ Create Property" button.

  4. Give your property a name - your website's name is a good choice. Set your reporting time zone and currency, then click "Next."

  5. Provide some basic business information. This is optional but helps Google tailor your dashboard experience. Click "Create."

Set Up Your Web Data Stream

A "data stream" is the specific source collecting data for your property. Since you have a website, you need to set up a web data stream.

  1. On the next screen, you'll be prompted to "Choose a platform." Select "Web."

  2. Enter your website's full URL (e.g., https://www.yourwebsite.com) and give the stream a name (e.g., "My Website").

  3. Ensure "Enhanced measurement" is turned on. This feature automatically tracks important interactions like scrolls, outbound clicks, and file downloads without any extra setup.

  4. Click "Create stream."

After creating the stream, you'll see a page titled "Web stream details." You'll need one critical piece of information from this screen for the next steps: your Measurement ID. It's located in the top-right corner and starts with "G-" (e.g., G-XYZ123ABC). Copy this ID or keep this tab open, you'll need it soon.

Method 1: The Easiest Way with a WordPress Plugin

For most WordPress users, especially those not comfortable with code, using a dedicated plugin is the simplest and safest installation method. These plugins handle the code placement for you and often come with extra features. The most straightforward option is Google's own "Site Kit" plugin.

Install GA4 with the Site Kit by Google Plugin:

  1. Install and Activate Site Kit: From your WordPress dashboard, navigate to Plugins → Add New. Search for "Site Kit by Google," click "Install Now," and then "Activate."

  2. Start the Setup Wizard: Once activated, you'll see a banner at the top of your dashboard. Click the "Start Setup" button.

  3. Connect Your Google Account: The wizard will guide you through connecting your Google account. You’ll need to grant the plugin permissions to access your Google Analytics data. Follow the on-screen prompts to sign in and approve the connection.

  4. Verify Site Ownership: Site Kit will automatically handle the site ownership verification through Google Search Console. It’s a seamless process that requires a few simple clicks for permission.

  5. Connect Google Analytics: During the setup, the wizard will detect your new GA4 property. Ensure it's selected from the dropdown menu and click "Configure Analytics."

That's it! Site Kit adds the necessary tracking code to your website automatically. As a bonus, it also adds a dashboard within WordPress where you can see top-level data from Google Analytics, Search Console, and PageSpeed Insights without ever leaving your site.

Method 2: Manually Adding the GA4 Tracking Code

If you prefer to limit the number of plugins on your site or are comfortable making small code edits, you can install Google Analytics manually. This method involves pasting the GA4 JavaScript snippet (known as the Global Site Tag or gtag.js) directly into your WordPress theme's files.

Quick Warning: Editing theme files can be risky. One small mistake could break your site. It’s highly recommended to use a child theme for these edits. Changes made directly to a parent theme's files will be erased the next time the theme is updated.

Step 1: Get Your Global Site Tag (gtag.js) Snippet

  1. Go back to your GA4 property's "Web stream details" page.

  2. At the bottom, under "View tag instructions," find the tab that says "Install manually."

  3. You'll see a box with a JavaScript code snippet. This is your Global Site Tag. Click the copy icon in the top right of the box.

The code will look something like this:

<-- Google tag (gtag.js) --&gt,

Step 2: Add the Code to your header.php File

  1. In your WordPress dashboard, go to Appearance → Theme File Editor. (If you don't see this option, your hosting provider may have disabled it for security reasons.)

  2. From the file list on the right, find and click on the "Theme Header" or header.php file.

  3. Scroll down through the code in the editor until you find the closing </head> tag.

  4. Paste your copied Global Site Tag on the line directly before the closing </head> tag.

  5. Click the "Update File" button to save your changes.

The Analytics tracking code is now active on every page of your site.

Method 3: The Scalable Way with Google Tag Manager

Google Tag Manager (GTM) is a free tool that acts as a container for all your marketing and analytics scripts (called "tags"). Instead of adding multiple code snippets directly to your site for different tools (like the Meta Pixel, Google Ads conversion tracking, GA4, etc.), you add GTM’s code once. Then, you manage all other tags from within the GTM dashboard.

While this method has a slightly steeper learning curve, it’s the most powerful and flexible approach, especially for marketers managing multiple tracking scripts.

Step 1: Set Up and Install Google Tag Manager

  1. Go to the Google Tag Manager website and sign in. Create an account for your business.

  2. Next, create a new "Container." Name it after your website and select "Web" as the target platform.

  3. Once created, GTM will give you two code snippets: one to place in the <head> of your site and another to place in the <body>.

  4. The easiest way to add this to WordPress is with a plugin like "GTM4WP" or the general-purpose "Insert Headers and Footers." These give you dedicated fields to paste the GTM codes without touching your theme files. Follow the plugin instructions to add the code.

Step 2: Create Your GA4 Tag within GTM

Now that GTM is installed on your site, you need to tell it to send data to Google Analytics.

  1. Inside your GTM container dashboard, go to Tags → New.

  2. Give your tag a clear name, like "GA4 Configuration."

  3. Click "Tag Configuration" and choose "Google Analytics: GA4 Configuration" from the list of tag types.

  4. In the "Measurement ID" field, paste in your GA4 Measurement ID (the "G-..." ID you copied earlier).

  5. Next, click the "Triggering" section below. A trigger tells the tag when to fire. Choose "All Pages" to make it fire on every page view.

  6. Click "Save" to finish creating your tag.

  7. Finally, in the top right of your GTM dashboard, click "Submit" and then "Publish" to push your changes live to your website.

Your site is now sending data to GA4 through Google Tag Manager. Moving forward, you can add other marketing tags via the GTM interface without ever touching your website's code again.

How to Check If Google Analytics Is Working

After you've finished one of the installation methods, you need to confirm that everything is working correctly.

  1. Log into your Google Analytics account.

  2. On the left-hand navigation menu, go to Reports → Real-time.

  3. Open your website in a different browser window (or an incognito/private tab).

  4. Return to the GA4 Real-time report page. Within a minute or two, you should see at least one "user" appear on the map and in the "Users in last 30 minutes" card. You can also monitor your activity in the "Views by page title and screen name" report at the bottom of the page.

If you see a visit from your location, congratulations! Google Analytics 4 is successfully installed and tracking data from your WordPress site.

Final Thoughts

Installing GA4 on your WordPress site is foundational to measuring your growth. Whether you went with the simple plugin method, added the code manually, or implemented the scalable Google Tag Manager solution, you now have the tools in place to collect valuable visitor data and understand how people interact with your content.

Once data starts collection, the real work begins: turning dense analytics reports into clear, actionable insights. Wrestling with custom GA4 reports can feel like a full-time job. With Graphed, we connect directly to your Google Analytics account, so you can stop fighting with complex report builders. Instead, you can simply ask questions in plain English - like "Which blog posts brought the most traffic last month?" or "Show me a chart of new users by country" - and get instant dashboards and reports, saving you from the all-too-common reporting headaches.