How to Install Google Analytics on WordPress: Plugins vs Manual Setup
July 27, 2026
Author: Shusaku Yosa
There are several ways to install Google Analytics (GA4) on a WordPress site, and the one you pick has a lasting effect on how manageable things are later. A plugin gets you there in minutes, but that convenience comes at a cost.
This article compares the four installation methods available in a WordPress environment and sets out how to choose between them. It also covers the typical problems that throw measurement off for reasons specific to WordPress, and how to avoid them. Creating a GA4 account and the fundamentals of Google Tag Manager are outside its scope.
Four methods, and how to choose
The ways to install GA4 on WordPress fall into four broad categories.
- Use Site Kit by Google, the official Google plugin
- Use a dedicated analytics plugin such as MonsterInsights
- Output the tag directly via theme settings or functions.php
- Install via Google Tag Manager (GTM)
The choice comes down to how far you intend to extend measurement. If pageviews are all you need, a plugin is fine. If you plan to move into event tracking for conversions or clicks, use GTM.
Decision criteria
Work through these conditions.
- You run paid advertising, or plan to: GTM
- You want to track form submissions or button clicks as conversions: GTM
- You will add measurement tags beyond GA4, such as ad tags or heatmap tools: GTM
- None of the above applies and you simply want traffic numbers: plugin
- You expect to change themes frequently: plugin or GTM, not direct theme editing
When in doubt, choose GTM. Migrating from a plugin to GTM later is possible, but it is a common source of double-counting errors, and the effort involved usually exceeds what it would have cost to start with GTM.
Method 1: Site Kit by Google
Site Kit by Google is the official WordPress plugin from Google. Alongside GA4, it brings Search Console, PageSpeed Insights, and AdSense into the WordPress admin interface.
Installation steps
- From the WordPress admin, go to Plugins and then Add New, search for Site Kit, then install and activate it
- Open Site Kit from the admin menu and begin setup
- Sign in with your Google account and complete site ownership verification
- Complete the Search Console connection
- Then select Analytics and specify the GA4 property and data stream to connect
Benefits and limitations
Being the official plugin makes it dependable, and having Search Console queries alongside GA4 metrics on one screen is genuinely useful. Since no theme files are edited, there is no risk of the tag disappearing on a theme update.
The reports shown in the admin interface, however, stay at a summary level. Any deeper analysis means opening GA4 itself, so it is best not to expect too much from what you can see inside WordPress.
Important: combining it with GTM causes double counting
Site Kit has a setting to insert the Google Analytics code, and it is enabled by default. If a GA4 tag is also firing through GTM, the same pageview is sent twice and your numbers roughly double.
Site Kit does display a warning that an existing tag was found on the page, but this warning is frequently missed, and the double counting goes unnoticed.
If you are using GTM alongside it, disable Site Kit's code insertion as follows.
- From the WordPress admin, open Site Kit and then Settings
- Select the Connected Services tab
- Choose Analytics
- Turn off the option to place the Google Analytics code
After changing the setting, open the GA4 realtime report and confirm your own visit is counted once. Checking how many times gtag.js loads in your browser's developer tools is another effective method.
Method 2: A dedicated analytics plugin
Dedicated plugins such as MonsterInsights and ExactMetrics install GA4 and additionally surface detailed reports inside the WordPress admin. Some offer extras such as e-commerce purchase data or form submission tracking.
The in-admin reporting is richer than Site Kit's, but the main features are typically reserved for paid tiers. Check what the free version actually covers before committing.
The same caution about duplication with GTM or theme-level tags applies here. Installing several plugins that each output a GA4 tag, resulting in triple counting, does happen in practice.
Method 3: Installing directly in the theme
If you would rather not add another plugin, you can output the tag from the theme. This approach carries clear risks.
Using the theme's settings field
Many themes provide a dedicated field for a measurement ID or header tag. Entering the GA4 measurement ID, which begins with G-, in the theme settings completes the installation.
Older themes may still have a field for the legacy Universal Analytics tracking ID beginning with UA-, but the GA4 measurement ID alone is sufficient now. If the theme only offers a UA field, it most likely does not support GA4, so choose a different method.
Editing functions.php or header.php directly
If you are editing theme files, always do it in a child theme. Editing the parent theme directly means your changes are overwritten when the theme updates, and the tag disappears. Going weeks without noticing that measurement has stopped is a common outcome.
The tag also disappears the moment you switch themes. This is why GA4 installation is so often forgotten during a site redesign, leaving a gap in the data.
For these reasons, installing directly in the theme is not recommended unless you have a specific constraint that rules out adding any plugins.
Method 4: Installing via Google Tag Manager
Using GTM takes more effort upfront but is the most manageable option over the medium to long term.
You install the GTM container snippet on WordPress and create the GA4 configuration tag within GTM. The snippet itself can be placed through Site Kit, a theme settings field, or a dedicated plugin, whichever you prefer.
Why GTM is worth it
- Tags can be added and changed without touching WordPress, so theme and plugin updates have no effect
- Tags other than GA4, such as ad conversion tags and heatmap tools, are managed in one place
- Event tracking for clicks, scrolls, and form submissions can be implemented through interface configuration alone
- Preview mode lets you verify behaviour before publishing
If you plan to run advertising or track conversions on a WordPress site, building on GTM from the start makes subsequent work considerably easier.
Problems specific to WordPress
Even when the installation itself is correct, measurement can still go wrong in a WordPress environment for the following reasons.
Caching plugins preventing tag delivery
If you use a caching plugin such as WP Super Cache or W3 Total Cache, cached HTML from before the change may continue to be served immediately after installing the tag, so measurement never starts.
Always clear the cache after installing the tag. If measurement still does not begin, check whether JavaScript minification or concatenation is enabled in the caching plugin's settings. Where these features interfere with the tag, you will need to exclude it from their scope.
Internal traffic contaminating the data
When your own visits are included in measurement, the numbers skew badly, particularly in the early period when traffic is low. The standard remedy is to define internal traffic in GA4 and exclude it.
In the GA4 admin, go to Data Streams, select the relevant stream, open the tag settings, and then Define internal traffic, where you register the IP addresses to exclude.
Note that this assumes a static IP. It will not work on home or mobile connections with dynamic addressing, in which case you will need to look at exclusion via a GTM custom variable or a cookie.
Preview and admin screens being measured
Depending on the installation method, the WordPress admin and post preview screens can end up within the measurement scope. Since these are not real user behaviour, your own editing work accumulates as pageviews.
Most plugins have an option to exclude administrator visits from measurement, so check for it after installing. If you are writing the tag into the theme directly, you will need conditional logic to exclude the admin screens.
Always verify after installation
Once installation is complete, check these three things.
- Open the GA4 realtime report and confirm your own visit appears
- Confirm the figure has not doubled, which would indicate double counting
- Confirm measurement works not just on the homepage but on post pages, static pages, and category pages
The third point is the one most often missed. Depending on how the theme is structured, the tag may not be output on certain templates, leaving some pages outside the measurement scope.
Summary
For installing GA4 on WordPress, what matters is less the method itself than choosing with your future measurement scope in mind. If traffic numbers are the goal, a plugin is sufficient, but if conversion tracking or advertising is on the roadmap, it is worth accepting the upfront effort and building on GTM.
Installing directly in the theme risks losing the tag on updates or theme changes, and should be avoided without a specific reason.
Whichever method you choose, verify three things without exception: double counting, the effect of caching, and internal traffic exclusion. Skip these checks and start collecting, and the accumulated data itself becomes unreliable, with no way to correct it retrospectively.

