Setup & site building · Guide
How to Add Google Analytics 4 to WordPress

Short answer
To add Google Analytics 4 to WordPress, create a GA4 property and a Web data stream in Google Analytics, copy the Measurement ID that starts with G-, then install Site Kit by Google and connect Analytics. Check the Realtime report within 30 minutes to confirm data is flowing.
Key takeaways
- A GA4 property needs a Web data stream, and the Measurement ID starts with G-.
- You need the Editor role to add properties, and an account can hold up to 2,000 properties.
- Site Kit by Google is free, needs WordPress 5.2 or newer and PHP 7.4 or newer, and places the tag for you.
- Data collection may take up to 30 minutes to begin, so check the Realtime report after that.
- Enhanced measurement records page views, scrolls at 90 percent depth, outbound clicks and file downloads.
- A standard property keeps user-level data for 2 months or 14 months, so set it to 14 months.
What is Google Analytics 4?
Google Analytics 4 (GA4) is the current version of Google Analytics, and it tracks visits and events on your site for free.
A GA4 property collects data from your site through a small tracking tag, then shows reports on who visits, which pages they read and where they came from. It replaces Universal Analytics, which used IDs starting with UA-.
If you open a property and cannot find a Data Streams option, Google's setup guide notes that you are in a Universal Analytics property instead of a GA4 property, according to Google's Analytics setup help.
GA4 is event-based: a page view is an event, and so are scrolls, clicks and downloads. That matters when you read reports, since you will see events and key events rather than the goals and sessions of the old version.
What do you need before you start?
You need a Google account, a live WordPress site, and Administrator access to that site.
GA4 setup happens in two parts: a property and data stream in Google Analytics, and a tag on your WordPress site. You need the Editor role to add properties to a Google Analytics account, according to Google's Analytics setup help.
If you created the account, you have the Editor role already. You can add up to 2,000 properties to one Analytics account.
On the WordPress side, only an Administrator can install plugins or edit theme files, so log in with an admin account before you start.
Your site must be live and reachable on the web: Google's own plugin notes that it cannot show data for a site that is not live, according to the Site Kit plugin page.
How do you create a GA4 property and data stream?
Create a property in Google Analytics, add a Web data stream, and copy the Measurement ID that starts with G-.
Follow the steps in Google's Analytics setup help:
- Go to analytics.google.com and click Start Measuring if this is your first account.
- In Admin, click Create, then select Account, and give the account a name.
- In Admin, click Create, then select Property, and enter a name, a reporting time zone and a currency.
- Pick your industry category and business size, then click Create and accept the terms.
- Under Data collection and modification, click Data Streams, then Add stream, then Web.
- Enter your site address and a stream name, leave enhanced measurement on, and click Create stream.
Your Measurement ID sits in the stream details panel and starts with G-, according to Google's Analytics setup help. Copy it exactly: one wrong character sends your data nowhere.
Pick the time zone and currency with care at setup, since changing the time zone only affects data going forward. For the property basics, Google's setup guide is the reference to keep open while you work.
How do you add GA4 with Site Kit?
Install Site Kit by Google, connect your Google account, and let it place the tag for you.
Site Kit is the official WordPress plugin from Google for insights about how people find and use your site, according to the Site Kit plugin page.
It is free, and it connects Analytics, Search Console, AdSense and PageSpeed Insights in one dashboard. It needs WordPress 5.2 or newer and PHP 7.4 or newer, according to the same plugin page.
Install it from the dashboard:
- Go to Plugins, then Add New, and search for Site Kit by Google.
- Click Install Now, then Activate.
- Open the Site Kit menu and follow the setup flow to connect your Google account.
- Under Site Kit, then Settings, then Connect More Services, connect Analytics and pick your property and stream.
Site Kit adds the Google tag for you, so there is nothing to paste by hand. It also connects Search Console during setup, which saves a separate step. If you want that part in detail, read how to connect Google Search Console to WordPress.
How do you add the Google tag by hand?
Paste the Google tag snippet right after the opening <head> tag on every page.
Find the snippet in your GA4 property under Admin, then Data Streams, then your Web stream, then View tag instructions, then Install manually. Google's setup guide shows the snippet starts with <!-- Google tag (gtag.js) --> and ends with </script>, according to Google's Analytics setup help.
The Google tag setup guide states that you should place the snippet immediately after the opening <head> tag on every page you want to measure, with your tag ID in place of TAG_ID.
In WordPress, add it in a child theme's functions.php with a wp_head hook, or with a code snippets plugin, so a theme update does not wipe it out. Do not paste it into the parent theme's files.
Do not add the tag twice: if Site Kit or another plugin already adds it, a second copy will count every page view twice. Pick one method only, and remove any older tracking code first.
How do you add GA4 with Google Tag Manager?
Put the Tag Manager container on the site once, then add the Google tag inside Tag Manager.
Google Tag Manager is a single container that holds all your tracking tags. You install the container snippet on the site, then create a Google tag inside Tag Manager with your G- Measurement ID.
Google's setup guide lists Tag Manager as one of the three ways to add the tag, alongside a CMS field and a manual install, according to Google's Analytics setup help.
Use Tag Manager when you run several tags, such as Analytics, ads and a chat tool, and want them in one place with versions.
Use Site Kit or the manual tag when Analytics is the only tag you need. For the full container setup, read how to add Google Tag Manager to WordPress.
| Method | Skill needed | Survives theme updates | Best fit |
|---|---|---|---|
| Site Kit plugin | Beginner | Yes | Most sites, one free plugin |
| Google tag by hand | Comfortable with code | Yes, in a child theme | Full control, no extra plugin |
| Google Tag Manager | Intermediate | Yes, if added by plugin or child theme | Several tags from one container |
| Theme settings field | Beginner | No, tied to the theme | Themes with a built-in tag field |
How do you check that data is flowing?
Open the Realtime report, visit the site in another browser, and look for your own visit within 30 minutes.
Data collection may take up to 30 minutes to begin, according to Google's Analytics setup help. After that, open Reports, then Realtime, and load a page on your site from a different browser or device.
Your visit should appear as one active user. If nothing shows after 30 minutes, check the tag first: open Tag Assistant at tagassistant.google.com and confirm your tag ID fires, as described in the Google tag setup guide.
Full reports take longer to fill in, so do not expect a full day of data on the first visit. If you use a cookie banner, accept it in your test browser, since declining consent can block the tag.
To keep your own visits out of reports, exclude your office address or use a filter, and read how to measure blog traffic in WordPress for what to watch once data arrives.
What does enhanced measurement track?
Enhanced measurement records page views, scrolls, outbound clicks, site searches, video plays and file downloads without extra code.
When you create a Web stream, Google recommends leaving enhanced measurement on, according to Google's Analytics setup help. The enhanced measurement help page states that no code changes are needed: once you enable the options, the tag starts sending events at once.
The page view event fires each time a page loads, and the scroll event fires the first time a visitor reaches 90 percent of a page. Outbound click events fire when a visitor clicks a link that leads away from your domain.
You can switch single events off in the stream settings if you do not want them. For example, turn off file downloads if your site serves many PDFs you do not need to track.
Events you care about most, such as a purchase or a form submit, can be marked as key events in the Admin area under Data display, then Events. For store tracking, read how to track conversions in WooCommerce with GA4.
How long does GA4 keep your data?
A standard GA4 property keeps user-level data for 2 months or 14 months, and you should set it to 14 months.
Google's data retention help page states that for GA4 properties you can set the retention period of user-level data to 2 months or 14 months, and that the same period applies to key events data.
The two-month setting is always applied to age, gender and interest data, whatever you pick. Longer periods of 26, 38 and 50 months are only open to Analytics 360 properties, according to the same help page.
Set the period under Admin, then Data Settings, then Data Retention, and pick 14 months unless you have a reason to keep less.
Note that the setting affects explorations and funnel reports, not the standard aggregated reports. Since the setting also applies to data already collected when you raise it, set it early, before your history builds up.
What mistakes should you avoid?
The common mistakes are double tagging, the wrong property, and ignoring consent rules.
Avoid these five mistakes:
- Installing the tag twice, for example with both Site Kit and a manual snippet, which counts every visit twice.
- Pasting the tag into the parent theme, where the next theme update deletes it.
- Using a Measurement ID from a test property or another site, so data lands in the wrong place.
- Leaving the retention period at 2 months and losing the history you need for year-on-year checks.
- Collecting visitor data without a consent banner or privacy notice where the law requires one.
GA4 is free, and the setup takes under an hour for most sites. The slow part is waiting for data and learning which reports matter, so keep the setup simple, check the Realtime report the same day, and review the privacy side in GDPR compliance for WordPress before you publish the tag.
If the tag slows your pages, read how to optimize Google Analytics for speed in WordPress for ways to cut its cost.
Frequently asked questions
Is Google Analytics 4 free?
Yes, Google Analytics 4 is free. There is no charge for a standard property, and Site Kit by Google is also free. Longer data retention and higher limits belong to the paid Analytics 360 version, which most small sites never need.
How do I know GA4 is working?
Yes, if you see data in the Realtime report within 30 minutes of adding the tag. Full reports take longer to fill in, so do not expect a full day of data on the first visit. If nothing shows, check Tag Assistant for your tag ID.
Can I use Site Kit and a manual tag together?
Yes, by picking only one method. Site Kit adds the tag for you, while a manual snippet or Tag Manager adds it another way. Installing it twice counts every page view twice, so remove the old tag before you add a new one.
What is a Measurement ID?
A Measurement ID starts with G- and identifies one GA4 web data stream. You need it to connect WordPress to the right property. Find it under Admin, then Data collection and modification, then Data Streams, in the stream details panel.
How long does GA4 keep my data?
Set it to 14 months under Admin, then Data Settings, then Data Retention. A standard property keeps user-level data for 2 months or 14 months, and the setting also applies to key events data. The 2-month setting is always applied to age, gender and interest data.
Does GA4 track scrolls and downloads on its own?
Yes. Enhanced measurement records page views, scrolls, outbound clicks, site searches, video plays and file downloads with no code changes. You can switch single events off in the stream settings if you do not want them.
Sources
- Set Up Analytics for a Website and/or App Google Analytics Help
- Enhanced Measurement Events Google Analytics Help
- Data Retention Google Analytics Help
- Set Up the Google Tag With gtag.js Google for Developers
- Site Kit by Google WordPress.org
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


