Add Google Analytics 4 to WordPress
To add Google Analytics 4 (GA4) to WordPress, create a GA4 property for your site, copy its Measurement ID (it starts with G-), and add that ID to your site through your theme's tracking setting or a plugin. Then check the Realtime report to confirm visits arrive. For Tag Manager, pixels, and other tracking codes, see Add tracking codes to your site.
Get a GA4 Measurement ID
Universal Analytics IDs (UA-…) no longer work. You need a GA4 property.
- Sign in to Google Analytics.
- Create an account and a GA4 property for your website, or open an existing one.
- Add a Web data stream for your site's URL.
- Copy the Measurement ID. It looks like
G-XXXXXXXXXX.
New to Analytics? Google's Getting started with Analytics covers account and property setup.
Add the Measurement ID to your site
Use one of these, not several:
- Your theme's tracking setting, if it has one. It's the simplest route, with nothing extra to install. On a Dirigible site, see below.
- Google Tag Manager, if your site already uses it. Add a Google tag with your Measurement ID inside Tag Manager instead of on the site.
- A plugin, such as Google's own Site Kit, which connects Analytics through your Google account.
Loading GA4 more than one way, for example through a plugin and through Tag Manager, counts every visit twice.
How do I check that GA4 is working?
- Open your site in a private (incognito) window. If a cookie banner appears, accept cookies.
- Click through a few pages.
- In Google Analytics, open Realtime (or use Tag Assistant). Your visit should appear within a minute or two.
Staging and local copies of a site sometimes block tracking. If nothing shows up there, test on the live site.
Seeing "(not set)" as a landing page in your reports? See Why GA4 shows "(not set)" as a landing page.
If your site runs on Dirigible
Dirigible has a field for the Measurement ID, so you don't need a plugin:
- Go to Appearance → Customize.
- Open Scripts & Embeds → Analytics & Tracking.
- Paste your Measurement ID into Google Analytics ID. The field also accepts Google's full install code and keeps just the ID.
- Click Publish.
If Google Tag Manager ID is filled in, Dirigible loads Tag Manager and ignores Google Analytics ID. In that case, add GA4 as a tag inside Tag Manager.
Leave Track Admin Sessions off on the live site so your own logged-in browsing doesn't inflate the numbers. If the GDPR Banner is on, Analytics waits until each visitor accepts cookies. See Set up a GDPR cookie consent banner.
Next steps
Google Search Console is separate
Analytics reports visitors. Search Console reports how your site shows up in Google search, and it's set up separately. See Add your WordPress site to Google Search Console.