How to add Google Analytics 4 to WordPress
Add GA4 to WordPress with Google's official Site Kit plugin, a header code plugin or WordPress.com's built-in setting, then check visits arrive in Realtime.
On a self-hosted WordPress site, the easiest way is Google's official Site Kit by Google plugin: install it, sign in with Google and connect your GA4 property. On WordPress.com, paste your Measurement ID in the built-in setting (on plans that allow it).
Option 1: Site Kit by Google (self-hosted)
In WordPress admin, go to Plugins → Add New, search for Site Kit by Google, then Install and Activate.
Choose Start setup and sign in with the Google account that owns (or should own) your analytics.
When asked, connect Analytics: pick your existing GA4 property, or let Site Kit create one.
Finish the setup. Site Kit adds the Google tag to every page.
Option 2: paste the tag with a header plugin
If you'd rather not use Site Kit, install a plugin that adds code to your site's <head> (such as WPCode), and paste the Google tag from GA4 (Admin → Data streams → your stream → View tag instructions → Install manually). Don't use both options at once, or visits are counted twice.
Avoid pasting the tag into your theme's header.php: a theme update can remove it.
Option 3: WordPress.com
On WordPress.com plans that allow it, paste your Measurement ID (G-…) into the Google Analytics setting in your site's settings, and save. WordPress.com's own support page shows exactly where it is on your plan.
Check it works
Open your site in a private window and GA4's Realtime overview. If you're logged in to WordPress, some setups don't track admins: test in a private window. More ways to check.
Related
Sources
- Google: Site Kit by Google
- WordPress.com: Connect to Google Analytics
Last updated
Webflow
Connect GA4 to Webflow with the built-in Google Analytics setting, or with custom code. Paste your G- Measurement ID, publish, and check Realtime.
Ghost
Add GA4 to your Ghost publication with code injection: paste the Google tag into the site header, save, and track newsletter signups as key events.