SEO & AI search · Guide
How to Use Google Analytics with WordPress: A Beginner's Guide

Short answer
Create a Google Analytics 4 property with a web data stream, then add its tag to WordPress using Site Kit by Google, a header code plugin or Google Tag Manager. Use only one method, check the Realtime report to confirm tracking, and add a consent banner where required.
Key takeaways
- Google Analytics 4 is the current version for all new setups.
- Site Kit is the easiest way to connect GA4 to WordPress.
- A header code plugin is a light alternative to Site Kit.
- Use only one method, or visits get counted twice.
- Confirm tracking with the Realtime report in a private window.
- Analytics cookies often need visitor consent.
How do you use Google Analytics with WordPress?
Create a Google Analytics 4 property with a web data stream, add its tracking tag to WordPress with Site Kit, a header code plugin or Google Tag Manager, then check the Realtime report.
Google Analytics tells you how many people visit your site, where they come from and what they do. WordPress does not include it by default, so you connect the two.
The setup takes about fifteen minutes. The bigger task is learning which reports matter and checking them regularly.
This guide covers setup, the three main ways to add the tag, the reports worth watching, and privacy points to keep in mind.
What do you need before you start?
You need a Google account, admin access to your WordPress site, and a few minutes to create a Google Analytics 4 property for the site.
Google Analytics 4, often called GA4, is the current version. The older Universal Analytics stopped processing data, so all new setups use GA4.
If your site uses a cookie consent tool, have it ready too. In many regions you need consent before loading analytics cookies. This is general information, not legal advice.
Step 1: How do you create a Google Analytics property?
Sign in at Google Analytics, create an account and a property, choose Web as the platform, enter your site URL, and copy the Measurement ID that starts with G.
Go to Google Analytics and follow the setup prompts:
- Create an account, usually named after your business.
- Create a property for the website, and set the time zone and currency.
- Add a Web data stream with your site's URL and name.
- Leave enhanced measurement on so page views, scrolls and outbound clicks are tracked.
- Copy the Measurement ID shown in the stream details.
If you use Site Kit, you can skip copying the ID, because the plugin can create or connect the property for you.
Use an email address on the Google account that you will keep long term. If a freelancer or agency sets up Analytics, ask them to create it under your account and add them as a user, rather than the other way round. That way you keep the data if you change providers.
Which method should you use to add the tag?
Use Site Kit if you want the easiest setup and stats in your dashboard, a header code plugin if you want something light, and Google Tag Manager if you manage many tags.
| Method | Best for | Pros | Cons |
|---|---|---|---|
| Site Kit by Google | Beginners | No code, stats in WordPress | Adds a larger plugin |
| Header code plugin | Light setups | Simple, small footprint | No dashboard reports |
| Google Tag Manager | Marketers, many tags | Flexible, manages many tools | More to learn |
| Theme or code snippet | Developers | No extra plugin | Lost on theme change if done wrong |
Pick one method only. Adding the tag twice counts every visit twice.
Step 2: How do you connect Google Analytics with Site Kit?
Install Site Kit by Google from Plugins, run its setup, sign in with your Google account, and choose to connect or create your Analytics property.
Site Kit by Google is Google's official WordPress plugin. It adds the tag for you and shows key stats inside your dashboard.
Steps:
- Go to Plugins, then Add New, search for Site Kit, install and activate it.
- Click Start setup and sign in with the Google account that owns or will own the property.
- Grant the permissions Site Kit asks for.
- Choose your existing GA4 property or let Site Kit create one.
- Finish setup and wait for data to appear.
Google's help article on setting up your Google tag with Site Kit covers the details. Our explainer on what Google Site Kit is describes what else the plugin does.
Step 3: How do you add the tag with a header code plugin?
Copy the Google tag code from your data stream, install a header and footer code plugin, and paste the code into the header section for every page.
In Google Analytics, open the web stream and view the tag installation instructions. Google shows a short script for the head of each page. Google's gtag.js installation guide explains how the tag works.
Then use a plugin such as WPCode to add it:
- Install and activate the plugin.
- Open its header and footer settings.
- Paste the Google tag code into the header box.
- Save.
Avoid pasting the code straight into a theme's header file. A theme update would erase it.
Step 4: How do you use Google Tag Manager instead?
Create a Google Tag Manager container, add its code to WordPress once, then add a Google tag inside Tag Manager using your GA4 Measurement ID.
Tag Manager is useful when you also run advertising pixels, heatmaps or event tracking. You manage all of them in one place without editing the site each time.
Our guide on adding Google Tag Manager to WordPress walks through the container setup.
If you use Tag Manager, do not also add the GA4 tag through Site Kit or a header plugin. Site Kit can connect to Tag Manager instead of placing the tag itself.
Step 5: How do you check that tracking works?
Open your site in a private window, then look at the Realtime report in Google Analytics; your visit should show up within a minute or so.
If nothing appears:
- Clear your caching plugin and CDN cache, since old pages may not have the tag yet.
- Check the page source for your Measurement ID.
- Turn off ad blockers in your test browser, because they often block analytics.
- Make sure your consent banner is not blocking the tag until you accept.
Standard reports can take a day or more to fill in, so use Realtime to confirm the setup.
Once data flows, connect Google Search Console to the same property. That adds search queries to your reports. Our guide on connecting Google Search Console to WordPress shows the steps.
Which reports should you look at first?
Start with traffic acquisition to see where visitors come from, pages and screens to see what they read, and engagement metrics to see whether they stay.
GA4 has many reports, but a few answer most site owner questions:
- Traffic acquisition: search, social, referral and direct visits.
- Pages and screens: your most viewed pages.
- Landing page: the pages where visits start.
- Engagement rate and average engagement time: how much attention pages get.
- Key events: actions you mark as important, such as form submissions.
Our guide on measuring blog traffic in WordPress shows how to turn these into a simple monthly check.
How do you track form submissions and sales?
Mark important actions as key events in GA4, using enhanced measurement, Tag Manager events or plugin integrations for forms and WooCommerce.
Enhanced measurement can detect some form interactions automatically, but it is not always accurate for every form plugin. Tag Manager triggers or a form plugin's built-in GA4 integration are more reliable.
For stores, ecommerce tracking needs product and purchase data sent to GA4. Many WooCommerce analytics plugins handle this. Our guide to setting up WooCommerce analytics compares the options.
Does Google Analytics slow down WordPress?
The tag adds a small script, so the impact is usually minor, but stacking several tracking tools and plugins can add up.
Keep the setup lean. Use one method to load the tag, and remove tracking tools you no longer check. Our guide on optimizing Google Analytics for speed covers delayed loading and other tweaks.
What about privacy and cookie consent?
In many regions, analytics cookies need visitor consent, so pair Google Analytics with a consent banner and mention it in your privacy policy.
Google offers consent mode, which changes how tags behave based on a visitor's choice. Many consent plugins support it. Our guide on adding a cookie consent banner explains the setup.
If you prefer fewer privacy concerns, cookie-free analytics tools are an option. Our comparison of Google Analytics vs privacy-friendly analytics weighs the trade-offs. This is general information, not legal advice; check the rules that apply to your audience.
Frequently asked questions
Is Google Analytics free for WordPress sites?
Yes. Standard Google Analytics 4 is free for most websites, and Site Kit by Google is a free plugin. Google sells a paid enterprise version for very large organizations, but small and medium sites rarely need it. Some third-party analytics plugins charge for extra features.
Why is Google Analytics showing no data?
The tag may be missing from cached pages, blocked by a consent banner or ad blocker, or added with the wrong Measurement ID. Clear caches, check the page source for your ID and test in a private window using the Realtime report. Standard reports can take a day to fill in.
Can I see Google Analytics stats inside WordPress?
Yes, with Site Kit by Google or another analytics plugin that pulls GA4 data into the dashboard. Site Kit shows visitors, top pages and traffic sources. For deeper analysis, such as custom reports and explorations, use the Google Analytics website itself.
Should I use Site Kit or Google Tag Manager?
Use Site Kit if you only need Google Analytics and want simple stats in WordPress. Use Tag Manager if you manage several tracking tools, such as ad pixels or heatmaps, or need custom event tracking. Do not load the GA4 tag through both.
Do I need a cookie banner for Google Analytics?
In many regions, including the EU and UK, analytics cookies generally need consent before they load. Other regions have different rules. A consent plugin with Google consent mode support is a common approach. This is general information, not legal advice, so check the rules for your audience.
Sources
- Site Kit plugin (WordPress): Set up your Google tag Google Analytics Help
- Site Kit by Google WordPress.org
- Install the Google tag Google for Developers
- Google Analytics Google
- WPCode – Insert Headers and Footers 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.


