Black Friday: Kinsta 50% off for 3 months · WPX first month $1.80 · InMotion up to 73% off — See the 4 hosting deals →
WORDPRESS GUIDE

How to add Google Analytics 4 to WordPress in 2026

WordPress does not include analytics, so the numbers have to be connected by hand. This guide creates the GA4 property, finds the Measurement ID, and adds it to WordPress four ways — Site Kit, a plugin, manual code or Tag Manager — then verifies the data and sets the five settings that keep it clean.

Published November 21, 202626 min readBy Sharjeel Tahir
Google Analytics 4 on WordPress: a line chart trending upwards on a dark dashboard

What Google Analytics 4 is — and what happened to Universal Analytics

Google Analytics 4, usually shortened to GA4, is Google's free tool for understanding what happens on a website: how many people visit, which pages they read, where they came from, what device they use, and what they do before they leave. Without analytics, you are publishing blind — you cannot tell whether a post is being read, whether search traffic is growing, or whether visitors leave after five seconds.

GA4 is the only version of Google Analytics Google runs now. The previous version, Universal Analytics, stopped processing new data in July 2023, and Google later shut its data off entirely. That matters in two ways. First, an old tracking ID starting with UA- does nothing any more — pasting one into WordPress collects nothing. Second, GA4 measures the site differently, so numbers from the old system and the new one do not line up, and comparing them directly will mislead you.

The biggest difference is the data model. Universal Analytics was built around sessions — a visit was the unit of measurement, and everything inside it was a hit. GA4 is built around events: everything a visitor does is an event — a page view is an event called page_view, and so are a scroll, a file download, an outbound click and a video play. Sessions still exist in GA4, but they are calculated from events rather than being the starting point.

WordPress does not include analytics out of the box: no tracking code, no dashboard, no connection to Google. Adding GA4 is a job you do once, deliberately, and then leave running. The job is small: creating the property and connecting it takes about fifteen minutes, and there are four ways to do it — a free official plugin, a dedicated analytics plugin, a few lines of code pasted by hand, or Google Tag Manager. This guide covers all four, then shows how to check the data is flowing and which settings to change before the data has had time to go wrong.

One warning applies to every method: use exactly one of them. Installing GA4 twice — through a plugin and by pasting the code as well — counts every visit twice, and inflated numbers are worse than none because they look plausible.

Before you start: what you need

Three things, and nothing else. First, a Google account — the same one you will use to sign in to Google Analytics. If the site belongs to a business, use the business Google account rather than a personal one: whoever owns the account controls the data, and moving a property later is awkward. Second, administrator access to the WordPress site: installing a plugin or editing theme files needs the manage_options capability, which is what an administrator account has. Third, about fifteen minutes of uninterrupted time, because the setup crosses two systems — Google Analytics and WordPress — and stopping halfway leaves the tag half-installed.

It also helps to decide your method before you start. If you want the simplest route, choose Site Kit — method one below. If you want the reports inside the WordPress dashboard, choose MonsterInsights — method two. If you want no extra plugin and you are comfortable editing code, choose the manual method — method three. And if you expect to add more tracking later, such as advertising pixels or custom events, choose Google Tag Manager — method four. There is no wrong choice; read the comparison in section nine if you are unsure, then come back here.

The one piece of information every method needs is the Measurement ID. It looks like G- followed by ten letters and numbers, for example G-XXXXXXXXXX, and it connects your site to your property. Sections three and four show how to create the property and find the ID. You cannot skip them: even the plugin methods need a property to exist first.

Step 1: Create your GA4 property

Everything starts at analytics.google.com. Sign in with the Google account you chose; if this is your first time using Analytics, click Start Measuring. If you already have an Analytics account, open Admin and click Create, then select Account to make a new one for this site. An account holds properties, and a property collects data for one website — a separate property per site is the normal arrangement, and one account can hold many. Give the account a name that matches the business or the site, choose your data-sharing settings, and click Next.

Now create the property itself. In Admin, click Create and select Property. Name the property — the site's name is the obvious choice — and select the reporting time zone and currency. The time zone matters more than it looks: every report is built in the property's time zone, so a Tuesday visitor can be counted on Monday if your property is set a day behind. Changing the time zone later only affects data going forward, so pick the time zone where the site's audience lives, or your own, and leave it alone afterwards. Then choose the industry category and the business size, and click Next again.

The last screen asks how you intend to use Analytics — generating leads, driving online sales, raising brand awareness, and similar options. Google uses the answer to choose which default reports to show you first; it does not lock anything in. Pick the closest match and click Create, then accept the Analytics Terms of Service and the Data Processing Amendment. The property now exists, but nothing is being tracked yet — it is an empty bucket waiting for a data stream, which is step two.

Two details worth noting: creating a property needs the Editor role on the account — if you created the account yourself, you have it automatically. And do not create a second property for the same site "just in case": a site with two properties splits its data between them, and neither report tells the whole story.

Step 2: Add a web data stream and find your Measurement ID

A property collects nothing until it has a data stream — the connection between the property and one website or app. In Admin, under Data collection and modification, click Data Streams, then Add stream, then Web. Enter the website's URL — just the domain, such as example.com — and give the stream a name, such as the site's name followed by "web stream". Leave Enhanced Measurement switched on; it is on by default.

Enhanced measurement is worth keeping: it collects page views, scrolls past 90% of a page, outbound clicks, site searches, video engagement and file downloads without extra setup. Google's own documentation recommends leaving it on, and you can switch individual events off later. Click Create stream — the Measurement ID appears at the top of the stream details page, starting with G-.

Copy that ID and keep it safe for the next ten minutes. It is the only value the WordPress side of the setup needs, and every method below either asks you to paste it or finds it for you after you sign in with Google. If you ever need it again, the path back is the same: Admin, then Data Streams, then the web stream — the Measurement ID sits under Stream Details.

Before moving on, check two things. First, that the stream is the Web type, not iOS or Android — the app streams are for mobile apps and will not track a website. Second, that you are looking at the right property: the property selector at the top of the Analytics screen shows the current one, and it is easy to create a stream in a property you did not mean to use. A stream created in the wrong property sends the site's data to a report nobody reads.

Method 1: Google Site Kit — the official plugin

Site Kit is Google's own free WordPress plugin, and for most site owners it is the method to choose. It connects the site to GA4, Search Console, AdSense and PageSpeed Insights through one sign-in, and it adds the tracking code for you, so there is nothing to paste and nothing to edit. It also puts a small Analytics dashboard inside WordPress, so you can check the headline numbers without opening Google Analytics. Google's own setup documentation lists Site Kit as one of the two WordPress integrations it supports, alongside MonsterInsights.

Start in the WordPress dashboard: go to Plugins, then Add New, and search for "Google Site Kit". Click Install Now, then Activate, and the setup wizard launches automatically. Click Start setup and sign in with the Google account that owns the GA4 property from sections three and four. Site Kit asks for permission to access your Google account — grant it, because without that permission it cannot see your properties or add the tracking code.

Next, Site Kit shows a setup checklist. Open the Analytics module and choose the property you created from the dropdown, along with its web data stream. Site Kit places the tracking code on the site and marks the module as connected. If the checklist also offers Search Console, connect it too while you are here: it costs nothing, takes one click, and unlocks the search queries report in section twelve. When the checklist shows green ticks, setup is done.

Give it a few minutes, then open the Site Kit dashboard in WordPress. The Analytics section should start showing visitors once data begins flowing — real-time data can take up to thirty minutes to appear, and the full reports up to forty-eight hours, so an empty first screen is normal, not a failure. Section ten shows how to confirm the connection properly.

Two cautions. First, if the site already has GA4 code on it from an earlier attempt — a pasted snippet, another plugin, a theme setting — remove it before activating Site Kit, or the site will be tracked twice and every number doubled. Second, Site Kit is tied to the Google account you signed in with: if that account loses access to the property, the connection breaks, so keep the property owned by an account the site will keep.

Method 2: A dedicated analytics plugin — MonsterInsights

MonsterInsights is the most-installed third-party analytics plugin for WordPress, with more than three million active installs. Choose it if you want the reports inside the WordPress dashboard rather than in Google Analytics. The free version covers the basics — connecting GA4 and showing an overview report — while the paid version adds pre-built tracking for forms, e-commerce, affiliate links and video embeds. For a site that only needs to know its traffic, the free version is enough.

Install it like any plugin: in the WordPress dashboard, go to Plugins, then Add New, search for "MonsterInsights", click Install Now, then Activate. A setup wizard opens and asks what kind of site you run — a blog, a business site or an online store — which shapes the reports it highlights. Then it asks you to connect to Google: click Connect MonsterInsights, sign in with the Google account that owns your GA4 property, and grant the permissions it asks for. The wizard then shows your properties — select the one you created and the matching web data stream, and finish the wizard.

MonsterInsights now adds the GA4 tracking code to every page, and it adds a Reports section to the WordPress dashboard, with an Overview report showing sessions, page views, top pages, top sources and device breakdowns. It also tracks outbound link clicks and file downloads automatically, which appear in the reports without further configuration.

The trade-off is the same as with any third-party plugin: you are adding code you do not control, and the free version shows upgrade prompts for its paid features. If that bothers you, Site Kit or the manual method keeps the site closer to Google's own code. The double-counting rule applies too — if Site Kit or a pasted snippet is already adding the GA4 code, remove it first.

Method 3: Add the tracking code by hand

The manual method is for site owners who want no extra plugin and want to know exactly what code is on their pages. It takes five minutes and one copy-and-paste, but it carries two responsibilities the plugin methods handle for you: the code has to be placed on every page, and it has to survive theme updates.

First, get the code: in Google Analytics, go to Admin, then Data Streams, click your web stream, and under Google tag click View tag instructions. On the installation instructions page, select Install manually. You will see the Google tag — a short JavaScript snippet that begins with a comment line and ends with a closing script tag, with your Measurement ID in two places. 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>

Google's instruction is to paste the tag immediately after the opening head tag on each page. On WordPress, the safe way is a headers and footers plugin — a small, free plugin whose only job is to add code to the head section of every page without touching the theme. Install one, paste the tag into its head field, save, and every page carries the code, including pages added later.

The alternative is to add the code through the theme. The correct route is a child theme's functions.php file, using the wp_head hook:

add_action( 'wp_head', 'add_ga4_tracking' );
function add_ga4_tracking() {
  ?>
  <!-- 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
}

Never paste the snippet into the parent theme's files directly: the next theme update overwrites them, the tracking disappears silently, and the gap is only noticed weeks later when a report looks empty. Never paste it into the WordPress editor or a page either — the tag belongs in the head section, not in a post. If editing functions.php feels risky, use Site Kit instead; the data is identical either way.

Method 4: Google Tag Manager — the most flexible route

Google Tag Manager, usually called GTM, is a container you install once on the site; afterwards you add and change tracking tags from GTM's own dashboard without editing the site again. Choose it if you expect to add more than Analytics — advertising pixels, custom events, form tracking, or a second analytics tool — because each becomes a tag inside the container rather than another snippet pasted into WordPress. The price is a longer setup: GTM adds a layer between the site and Google, and that layer has its own learning curve.

Start at tagmanager.google.com and create a container for the site's domain. GTM gives you two snippets: one goes immediately after the opening head tag, the other immediately after the opening body tag. Add both through a headers and footers plugin or a child theme, exactly as in the manual method — never in the parent theme's files, because a theme update would remove them.

Now add GA4 inside the container. In GTM, create a new tag and choose the Google tag type — current Tag Manager shows this as "Google Tag"; older accounts show "Google Analytics: GA4 Configuration". Paste your Measurement ID into the tag ID field, then set the trigger to All Pages so the tag fires on every page load. Save the tag, then click Preview: Preview mode opens the site in a debug window showing which tags fired. Visit a page and check that the Google tag fired with your Measurement ID — if it did not, the trigger or the ID is wrong, and fixing it now is far easier than after publishing.

When the preview looks right, click Submit and then Publish in GTM. Publishing is the step people forget — tags configured in GTM do nothing until the container version is published, and an unpublished container leaves the site untracked while everything looks finished. After publishing, the GA4 data starts flowing, subject to the same thirty-minute wait as the other methods. From here on, new tracking is added inside GTM: a conversion event is a new tag with its own trigger, and the site itself is never edited again.

Which method should you choose?

All four methods collect the same data, so the choice is about how you prefer to work, not about the quality of the reports. Site Kit is the easiest for most sites: free, Google's own plugin, it adds the code for you and connects Search Console at the same time. Choose it unless you have a specific reason not to. MonsterInsights is the right choice if you want the reports inside WordPress and you like its overview dashboard — its free version covers a blog or a small business site. The manual method is the lightest: no extra plugin, no third-party code, just the Google tag in the head of the site. Choose it if you are comfortable with code and you want the site to carry as little as possible. Tag Manager is the most powerful and the most work: choose it if you plan to add more tags later, or already use it for other tracking.

Two situations decide the choice for you. If the site runs on a managed host or a page builder that restricts plugins, the manual method or Tag Manager may be the only routes that work. And if more than one person manages the site, prefer a method the whole team understands: a plugin with a visible dashboard beats a hand-pasted snippet that only one person knows about, because the snippet gets deleted during the next theme change. Whichever method you pick, write it down — a note in the site's documentation, or a comment in the code — so the next person does not add a second copy.

How to check GA4 is actually working

Do not assume the installation worked. Google says data collection may take up to thirty minutes to begin, so wait at least that long, then open the property in Google Analytics and go to Reports, then Realtime. In another browser tab, visit the site yourself — open the homepage and click through to a post. Back in the Realtime report, you should see one active user, which is you, and the page you are on should appear in the list. If it does, the connection works; everything else is a matter of waiting for the standard reports to fill in, which can take up to forty-eight hours.

If the Realtime report shows nothing, work through the checklist in order. First, check the Measurement ID: compare it character by character with the one on the stream details page — a single wrong character sends data to a property that does not exist. Second, check for a double installation: if Site Kit is active and a snippet is also pasted in the head, remove one of them. Third, check the property selector at the top of Google Analytics — you may be looking at a different property. Fourth, clear the site's cache and reload: a caching plugin or the host's server cache can keep serving the page from before the tag was added, and a private browser window rules that out in seconds.

Fifth, check your own browser: an ad blocker or a strict privacy extension can block the Google tag on your machine, making the Realtime report look empty even though real visitors are being counted. Test from a different browser or a phone with no blocker. Sixth, check whether a consent banner is blocking the tag: if it only fires after acceptance, your own visit without accepting will not be counted — accept the banner, then look again. If none of these explains it, use Tag Assistant at tagassistant.google.com: it reports whether the tag loaded, which ID it used, and any errors.

One more check is worth doing in the first week: open DebugView in Google Analytics while browsing the site with debugging switched on, and watch the events arrive one by one — page_view, scroll, and any clicks you make. DebugView shows the raw event stream, the fastest way to confirm that enhanced measurement is recording the events you expect, rather than only page views.

Five settings to change right after setup

A fresh GA4 property works out of the box, but five settings make its data much cleaner — and all five are easier to set in the first week than to fix months later, when the bad data is already mixed in.

First, extend the data retention. GA4 keeps event-level data for two months by default, which means older reports are built from aggregated data you cannot break down. Go to Admin, then Data Settings, then Data Retention, and change the event data retention to fourteen months — the longest GA4 allows. It only affects data collected from now on, so set it on day one.

Second, filter out your own visits. Your own browsing inflates the numbers and distorts the behaviour reports, because you click through pages no real visitor would. In Admin, go to Data Settings, then Data Filters, and define your internal traffic by the IP address of the office or home connection, then create a filter that excludes it. Test it first: the filter has a testing mode that shows what would be excluded.

Third, list unwanted referrals. When a visitor pays through a payment gateway and returns to the site, GA4 can count the gateway as the source of the visit, making it look as if the payment provider sent you traffic. In Admin, open the web data stream, then Configure tag settings, then List unwanted referrals, and add the domains of the payment gateways and any service the site hands visitors to and back from.

Fourth, link Search Console. In Admin, go to Product links, then Search Console links, and connect the site's Search Console property. This unlocks the Queries report inside GA4 — the search terms that brought visitors to the site — the single most useful report for deciding what to write next. Our keyword research guide shows how to use those queries to find topics people actually search for.

Fifth, mark your key events. GA4 calls conversions "key events": in Admin, open Events, find the events that matter to the site — a form submission, a file download, a completed purchase, a click on a contact link — and mark them as key events. From then on GA4 counts them separately, turning "people visited" into "people visited and did the thing the site exists for".

Your first week with GA4: the six reports that matter

GA4 has dozens of reports; opening the full list on day one is a good way to close the tab and never come back. Six reports cover almost everything a small site needs.

Start with the Realtime report, under Reports, then Realtime. It shows who is on the site right now — the page they are on, where they came from, what device they use. Use it to confirm the installation, and later to watch the immediate effect of a new post or a shared link. It only covers the last thirty minutes, so it is a pulse check, not a trend.

Next, Traffic acquisition, under Reports, then Acquisition: where visitors came from — organic search, direct visits, social media, referrals and email. The question it answers is which channel is actually bringing people, and the answer often surprises site owners: a channel they ignore may be doing more work than the one they spend hours on. If organic search is small and growing, search visibility is the lever; if social brings visits but nobody stays, the content or the landing page is the problem, not the channel.

Then Pages and screens, under Reports, then Engagement: the most-visited pages and how long people engage with each one. A page with many views and low engagement time promises something its content does not deliver; a page with modest views and long engagement is worth promoting. Sort by views, then look at engagement time on the top ten — those pages are where the site's value lives.

Fourth, the Engagement overview, also under Reports, then Engagement: average engagement time per session and per user, and how many sessions lasted more than ten seconds or included a key event. This is the report that tells you whether the site is being read or merely glanced at, and the one to watch after a redesign or a speed fix — our WordPress speed optimisation guide covers the fixes that move these numbers.

Fifth, the Search Console queries report, under Reports, then Search Console, once the two products are linked as described in section eleven. It lists the exact search terms people typed before clicking through, and the pages those clicks landed on. A query with many impressions and few clicks is a page ranking on the second page that deserves a better title; a query you had never thought of is a new post waiting to be written.

Sixth, the Events report, under Reports, then Engagement, then Events: every event GA4 recorded — page views, scrolls, outbound clicks, downloads, video plays — with counts for each. With enhanced measurement on, the scroll and outbound-click events are already there, answering a question page views cannot: are people reading to the bottom, and clicking the links you want them to click? Check this report weekly for the first month.

Mistakes that break GA4 data — and how to avoid them

Most GA4 problems are not setup errors but slow data corruption: small decisions that quietly spoil the reports for months.

The first is installing the tag twice — the most common mistake of all, worth repeating from section one: two copies of the code, from any combination of plugin, pasted snippet and theme setting, double every number. If the traffic suddenly doubles overnight, a second copy of the tag is the first thing to check.

The second is comparing GA4 numbers with old Universal Analytics numbers as if they measured the same thing. They do not: GA4 counts sessions and users differently, and its engagement metrics have no direct equivalent in the old system. A drop between a UA report and a GA4 report usually means the measurement changed, not the traffic. Judge GA4 against its own past.

The third is treating the first forty-eight hours as final. GA4's standard reports fill in over one to two days, and the numbers move during that time. Do not write a post, check the report the next morning, and conclude it failed — wait two days, then judge. A new property with no traffic history takes time to show anything at all.

The fourth is ignoring consent rules. If the site's visitors include people in the EU, the UK or California, analytics cookies generally need consent before they load, and a consent banner that blocks the tag until accepted is the correct behaviour, not a bug. A site that loads GA4 before consent may collect data it should not have. If this applies to the site, add a consent banner and GA4's Consent Mode, which lets GA4 model the missing data instead of recording nothing.

The fifth is filtering out real traffic by mistake. The internal-traffic filter from section eleven is powerful, and a wrong IP range can hide genuine visitors. Always use the testing mode first, and check the Realtime report after applying a filter. And the sixth is changing the Measurement ID mid-stream: replacing the ID on a live site splits the data between the old property and the new one, and the history cannot be merged back. If the property is wrong, fix the connection, but expect the old data to stay where it is.

Frequently asked questions

Is Google Analytics 4 free?

Yes. Google Analytics 4 is free, with no limit on the visitors a standard property can track. There is also a paid enterprise version, Analytics 360, for very large organisations, but a normal WordPress site never needs it. The plugins in this guide have free versions that cover the setup.

How long does GA4 take to start showing data?

Real-time data can take up to thirty minutes to appear, so check the Realtime report after half an hour, not five minutes. The standard reports take longer — up to forty-eight hours to fill in completely — and the numbers can move during that time. A property showing nothing after two days has a setup problem; start with the checklist in section ten.

Do I need a plugin to add GA4 to WordPress?

No. A plugin is the easiest route, but not a requirement. You can paste the Google tag into the site's head section by hand, through a headers and footers plugin or a child theme's functions.php file, or install it through Google Tag Manager. All four collect the same data — pick the one that fits how you work, and use only one.

Why is GA4 showing no data?

The usual causes, in order: the Measurement ID is wrong or belongs to a different property; the tag is installed twice; the site's cache is still serving the old page without the tag; an ad blocker or a consent banner is stopping the tag on your own browser; or you are looking at the wrong property. Check the Realtime report while visiting the site yourself, and use Tag Assistant to see whether the tag loads and which ID it uses.

Can I still use Universal Analytics instead of GA4?

No. Universal Analytics stopped processing new data in July 2023, and Google has since shut its data off entirely. A UA tracking ID, which starts with UA-, collects nothing any more. GA4 is the only version that works, so any old UA code on the site should be removed and replaced with a GA4 installation.

Does GA4 slow down my WordPress site?

Barely. The Google tag is a small script that loads asynchronously, so it does not block the page from rendering, and its effect on loading speed is minimal on its own. What slows a site down is stacking tags: GA4 plus several advertising pixels plus a heavy Tag Manager container, or the same tag installed twice. Keep it to one method, and the analytics tag itself is not a performance problem.

GA4 is running — now fix what it finds.

GA4 tells you what is happening on your site. The technical SEO basics guide covers the crawling, indexing and structure problems its reports point at.

Read the technical SEO basics guide ↗
Portrait of Sharjeel Tahir
About the author

By Sharjeel Tahir

He builds free online tools at sharjeeltahir.com and writes WordPress, SEO and hosting guides for site owners everywhere. (The steps in this guide were checked against the official Google Analytics documentation on 21 November 2026.)

Published: 2026-11-21