You publish a post, share it around, and then wonder what happened next. Did anyone read it? Did they leave after five seconds? Did they arrive from Google, from a a Substack post, or from a link somebody dropped on Reddit three months ago?
Without analytics on your site, you’re guessing. Google Analytics answers those questions for free, but connecting it to WordPress trips up many site owners because there are several ways to do it.
Below you’ll find how to set up a Google Analytics 4 property, five ways to connect it to your WordPress site, and how to confirm the tracking is working.
Table of Contents
What Google Analytics Tracks
Google Analytics loads a small JavaScript snippet on every page of your site. When somebody visits, that snippet sends events to Google’s servers. These can be a page view, a scroll, a click on an outbound link, a file download.
Here’s what the data gives you.
- Where visitors come from. Organic search, direct traffic, social platforms, referral links, and email campaigns.
- What they do after they arrive. Which pages get read, how long people stay, which links get clicked.
- Who they are in aggregate. Country, city, device type, browser, screen size, language.
- What happens in your store. Product views, add to cart actions, purchases, and revenue if you run WooCommerce.
None of that exists in WordPress on its own. Your dashboard shows comments and post counts, nothing about traffic.
Setting Up Your GA4 Property
Before you can install analytics on your WordPress site, you’ll need to setup your GA4 property.
First, sign in at Google Analytics using a Google account and click Start Measuring.

Then, you’ll need to enter some information, like your account name, property name (usually the name of your site), business details, and more.
After that, on the on the Set up data stream screen click the Web option, then enter your URL and website name and click Create & continue.
Once you’re finished, you’ll land on a screen that shows you your tracking code, which starts with G- followed by letters and numbers. Copy it somewhere safe, since most of the methods below need it. If you lose it, go to Admin > Data streams and click your web stream.
Five Ways to Add Google Analytics to WordPress
Make sure you only pick one of the five methods below. Installing the tracking code twice is the most common mistake in this process, and it doubles your pageviews while wrecking your engagement figures.
Method 1. Use the Site Kit by Google Plugin
Site Kit is Google’s own WordPress plugin and it’s completely free. It has over 5 million active installations, making it the most widely used option here.
What sets it apart is the range of data it pulls in. You’ll get Google Search Console, Analytics, AdSense, and PageSpeed all reporting into a single dashboard in WordPress, so search queries and traffic numbers are on the same screen.
Go to Plugins > Add Plugin, search for Site Kit by Google, then click Install Now and Activate.
After that, a Site Kit menu option will show up in your sidebar. Click it, then click Sign in with Google to begin the connection.
Make sure that you’ve signed in with the Google account that owns your Analytics property, grant the permissions so Site Kit can verify site ownership and read your data.
Then, you’ll be asked to setup Search Console if you’d like. Finally, you’ll get to the Analytics screen where you need to select the property and data stream you created earlier, and click Set up.
Every WordPress admin has to connect their own Google account to see data in the plugin, so on a multi-author site, everyone who wants access goes through the connection process themselves.
Method 2. Use the MonsterInsights Plugin
MonsterInsights is another popular option for adding Google Analytics to WordPress. There’s a free version that connects your site to GA4 and puts a simplified report in your dashboard. There’s also a premium version with much more advanced tracking available.
To install the free version, go to Plugins > Add Plugin, search for MonsterInsights, then click Install, and Activate.
Once you install the plugin the setup wizard will automatically start. All you need to do is follow the steps. First, select a category for your site, connect the plugin to your Google Analytics account, and grant all the necessary permissions.
After that, select the property that you created earlier and click Complete Connection.
Once it’s connected the plugin show you some recommended settings. Review these, finish the wizard, and your reports appear under Insights > Reports.
Method 3. Use WPCode or Another Snippet Plugin
If you don’t need reports in WordPress and want the tracking code on your site, a header-and-footer snippet plugin is the cleanest option. WP Code is one of the most popular code snippets plugins, and it handles any custom snippet you’d otherwise drop into functions.php.
First, grab your tracking code that you copied at the beginning of this post. If you don’t have it, then login to your Google Analytics account, go to Admin > Data streams, then click on your property.
After that, click View tag instructions at the bottom of the screen. Then click Install Manually and copy the code.
Next, install and activate WP Code from Plugins > Add Plugin. Then, a Code Snippets menu item will show up in your sidebar. Go to Code Snippets > Header & Footer, paste the tracking code into the Header box, and click Save Changes.
The code then loads on every page, will survive theme updates and theme switches, and disappears cleanly if you remove the plugin. You give up the WordPress dashboard reports and have to check your numbers inside your Google Analytics dashboard instead, but some users prefer this approach.
Method 4. Use Google Tag Manager
Google Tag Manager lets you manage all your tracking scripts from one place instead of adding each one to your site by hand. It’s more setup than the other methods, so it’s mainly worth it if you’re running ads or several tracking tools alongside Analytics.
First, go to Google Tag Manager, and click Sign in to Tag Manager.
Then, click Create Account.
After that, give your account a name, enter your URL, select Web as your target platform, and click Create.
Next, copy your Container ID at the top of the screen. It starts with GTM followed by numbers and letters. Don’t copy the entire code, just the portion that begins with GTM.
Next, click Tags on the left-hand sidebar. Then, click New to add a new tag.
On the screen that pops up click Tag Configuration, then select Google Analytics for your tag type.
Then, you need to paste in your Google Analytics tag, it’ll look something like G-BPRH2DL7KH. This is not the tag that you copied earlier. Instead, it’s inside the code that you copied in Method 3 above.
Below that make sure the trigger is set to All Pages. It should do this automatically. Then, click Save.

Now head back to your WordPress dashboard. Here, you need to add your tag to your site. You can do this by using a tag manager plugin, or by adding the container snippet code directly to your site by using a code snippets plugin.
We’ll use a tag manager plugin here, since it’s more straightforward. You’ll have a few different options to choose from, but the plugin GTM4WP is easy to use and highly rated.
Navigate to Plugins > Add Plugin and search for GTM4WP. Then, install and activate the plugin.
After that, go to Settings > Google Tag Manager and enter your tag ID and click Save Changes.
If you don’t remember where this ID is, then head over to your Google Tag Manager account, and then your tag ID is listed at the top of the page, just below the search bar.
Once that’s done, any tag you set up in Tag Manager runs on your site automatically, without you having to touch WordPress again.
Method 5. Add the Code to Your Theme
Another option is to paste the tracking code straight into your theme files, but this is the method we’d recommend least.
The problem is that theme updates wipe the edit, and switching themes removes your tracking with no warning. If you go this route, use a child theme so your changes survive updates, and back up your site before you touch anything.
First, grab your tracking code the same way as Method 3 above. Here’s a quick refresh, login to Google Analytics, go to Admin > Data streams, click your property, then click View tag instructions and Install Manually, and copy the code.
To edit your theme files, you’ll need to open File Manager in your hosting dashboard, or connect to your site via FTP using a tool like FileZilla or Cyberduck. Then navigate to your theme folder inside wp-content/themes. Editing files directly in the WordPress dashboard is riskier, since a single mistake can lock you out of your site, so working through File Manager or FTP is the safer choice.
Once you’re in your child theme folder, you can add the code in one of two places.
The simpler option is your header file. Open your child theme’s header.php file and paste the tracking code immediately before the closing </head> tag. Save the file and upload it back to your server.
The other option is your functions file, which adds the code to every page automatically. Open your child theme’s functions.php file and add the following.
add_action('wp_head', 'supporthost_add_ga_code');
function supporthost_add_ga_code() { ?>
REPLACE THIS LINE WITH YOUR GOOGLE TAG CODE
<?php }
Swap the middle line for your actual tracking code, then save the file and upload it back to your server.
Which Method Is Best For Your Site
Method | Cost | Reports in WordPress | Best for |
|---|---|---|---|
Site Kit by Google | Free | Yes | Most site owners, especially Search Console users |
MonsterInsights | Free version, premium from $99.50/year | Yes | Stores wanting event tracking without code |
WPCode | Free | No | Anyone who wants tracking with minimal overhead |
Google Tag Manager | Free | No | Sites running ads or several tracking scripts |
Theme files | Free | No | Developers on custom builds who know the risks |
Using the Site Kit or WPCode plugins cover what most people reading this need. If you have more in-depth tracking requirements it might make sense to use a premium plugin.
Making Sure Tracking Works
Everything you did above doesn’t matter if your tracking doesn’t work. Open your site in a private browsing window and click through two or three pages, then go to Reports > Realtime Overview in Google Analytics. You should see at least one active user and the pages you visited within a few seconds.
Keep in mind, it might take some time for your tracking code to confirm. Give it a little time before you move onto the troubleshooting section at the bottom of this post.
Google Analytics Reports to Check Out
GA4 has a lot of screens and gives you a ton of website data, but you don’t need all of this data. Here are the most valuable reports:
Realtime overview and realtime pages (seen above) shows who’s on your site right now. Useful in the hour after you publish something.
The Acquisition tab breaks down traffic sources. If you’re doing anything for SEO, you’ll spend most of your time here.
The Engagement tab covers which pages get viewed, average engagement time, and which events are triggered.
The User attributes and Tech shows location, devices, browsers, and screen sizes. Check it before making design decisions, since mobile traffic is usually higher than most site owners expect.
Excluding Your Own Visits
On a small site, your own traffic throws your numbers off. You’re on the site more than anyone, and every one of those sessions is captured in your reports. You’ll want to filter out your own traffic so your data is clean.
First, you need to define the traffic. Head back to your GA account and go to Admin > Data streams.
Then, click Configure tag settings.
Next, under Settings click on Define internal traffic.
Then, create a rule, name it, and add your IP address. These tags match visits with a traffic_type parameter set to internal. It labels them and nothing more.
The second step is the filter. Go to Admin > Data collection and modification > Data filters and find the Internal Traffic filter. If it’s currently on testing, then change it to Active.
Google Analytics and Privacy Rules
If you have a site with a lot of EU visitors, then understanding GDPR and privacy is important.
Google Analytics sets cookies and collects data that counts as personal data under GDPR. In most European jurisdictions, you need consent before the tracking script loads. A cookie banner that appears while GA is already running doesn’t meet the requirement.
Google Consent Mode handles this and has been mandatory since March 2024 for anyone using Google tags with visitors in the EEA and the UK. In Basic mode, Google tags don’t run until consent is granted. In Advanced mode, tags fire immediately but send only cookieless pings when consent is denied, then update once the visitor chooses.
Setting Up Cookie Consent
Google Consent Mode doesn’t come with a banner of its own. It’s the signal layer underneath, and it needs a cookie consent plugin sitting on top to show visitors the banner and collect their choice. CookieYes handles both, and unlike some alternatives, it includes Google Consent Mode on its free tier.
To install it, go to Plugins > Add Plugin, search for CookieYes, then click Install Now and Activate.
Once it’s active, a CookieYes menu appears in your sidebar. Open it, and it’ll generate. cookie banner right away. You can also let the plugin scan your site to improve your cookie policy. To do this, click Connect to a new account.
Once your site is connected you can manage your cookie banner from the CookieYes site. Here you can customize your banner, manage cookies and much more.
Back in your dashboard, go to CookieYes > Google Consent Mode in your WordPress dashboard and toggle Enable Google Consent Mode (GCM). Confirm it in the popup that appears. That switches on Basic Consent Mode, which holds Google tags until the visitor consents.
Rules vary by country, and some European data protection authorities take a stricter position on Google Analytics than others. For a business site in the EU, it’s worth discussing with whoever handles your compliance.
Does Google Analytics Slow Down WordPress?
The analytics tracking script is small and loads asynchronously, so it won’t block your pages from rendering. What might slow your site down are any plugins you’re using to add it.
A plugin that pulls reports into your dashboard makes API calls to Google, caches the results, and loads its own admin assets. On a shared plan with limited resources, you might notice the slowdown.
Use a tool like GTMetrix or Pingdom to get your current speed. Then, try using an alternative method like WP Code, run the reports again, and see if it makes a difference.
Hosting makes far more difference than any analytics plugin. If your site was already slow, a tracking script isn’t the reason. Our guide on how to speed up WordPress covers what actually helps, and if you’ve outgrown your plan, our WordPress hosting plans give you more room.
Troubleshooting Common Problems
Here are some of the most common problems you’ll run into when setting up Google Analytics WordPress:
No data at all. Check your measurement ID character by character against the one in Admin > Data streams. One wrong character sends your data nowhere. If you’re using the Tag Manager method, then the same thing applies.
Pageviews suddenly doubled. The tracking code is installed twice. Check your theme options panel for a built-in analytics field, look for a second analytics plugin, and remove one of them.
Realtime works, but standard reports are empty. Give it 24 hours.
Data stopped after a theme change. If you added the code to the theme files, it’s gone. Reinstall it with one of the plugin methods.
Numbers look inflated on a small site. That’s usually your own traffic. Work through both steps in the internal traffic section, including activating the filter.
Google Analytics WordPress FAQs
Is Google Analytics free?
Yes. The standard version costs nothing and covers the vast majority of WordPress sites. Analytics 360 is the paid enterprise tier, but it’s built for large organizations and priced accordingly, so it’s not something a normal WordPress site needs.
Do I need a plugin to use Google Analytics on WordPress?
No. A plugin makes it easier and lets you view reports without leaving WordPress, but the tracking itself is a single JavaScript snippet in your header. A snippet plugin or a child theme does the same job.
Can I use Google Analytics and Jetpack Stats at the same time?
Yes, they don’t conflict. Jetpack Stats gives you a quick traffic overview inside WordPress, while Google Analytics gives you far more detail on sources and behavior.
How long before I see data?
Real-time shows activity within seconds. Standard reports usually take 24 to 48 hours on a new property.
Are there alternatives to Google Analytics?
Yes. Matomo can be self-hosted, so your data stays on your server, while Plausible and Fathom are hosted, cookieless, and paid. They simplify your consent obligations, though none connect to Search Console or Google Ads, so the trade-off depends on whether you’re running campaigns or just reading your traffic.
Closing Thoughts on Google Analytics WordPress
Setting up Google Analytics WordPress comes down to properly configuring the GA4 property, then choosing one method to add the code to your site.
Site Kit is the obvious choice if you want reports inside your dashboard without paying anything. A code snippet plugin like WPCode takes about three minutes if you want the lightest setup possible. While, Tag Manager is worth the extra work if you’re running ads or juggling several scripts. Leave the theme file method alone unless you have a specific reason and a child theme already in place.
Whichever route you take, check the Realtime report to confirm it’s working, filter out internal traffic, and get your consent setup sorted if you have European visitors.
Now over to you. Which method did you use to connect Google Analytics to your WordPress site, and did you run into anything unexpected along the way? Please share your experience in the comments below.
Ready to build your WordPress site?
Try our service free for 14 days. No obligation, no credit card required.