Skip to content
Compare
WordPress ThemesWebsite Builders & TemplatesE-commerceHosting & PerformanceSecurity & BackupsPlugins & Web ToolsAI for WebsitesDesign & UXNews Compare tools
News

Install Google Analytics in WordPress: 3 Ways Compared

Plugin, pasted code or Google Tag Manager: three ways to add Google Analytics to WordPress, who each suits, and the check that stops duplicate data.

Priya Nair December 3, 2026 Updated December 3, 2026 4 min read

You can install Google Analytics on WordPress in three ways: with a plugin, by adding the tracking code yourself, or through Google Tag Manager. According to One.com’s guide, the plugin route is the easiest and needs no code. The code route suits people who want control. Tag Manager pays off when you run several tags. Pick one method and stick with it, because running two at once can record every visit twice.

Before you start: get your Measurement ID

Every method begins in Google Analytics. Create a property with a web data stream, then copy the Measurement ID, which starts with G-. Google’s help pages say you find it on the web stream details page, under the tag settings. If you plan to paste code, copy the full Google tag as well, not just the ID.

Install Google Analytics in WordPress: 3 Ways Compared
Crédit : flutie8211 / Pixabay

Your site also has to be publicly reachable. One.com warns that maintenance mode and password protection block some plugin connections.

Method 1: a plugin (no code)

One.com lists three variants here.

Site Kit by Google. Install it from Plugins, then Add New, open the Site Kit menu and sign in with Google. You choose your property from a list instead of copying an ID. Google’s own documentation for CMS-hosted sites points WordPress users to Site Kit. It also connects other Google services, such as Search Console.
GA Google Analytics. You paste the Measurement ID into the tracking ID field, select GA4 as the tracking method and save. The cost is one more plugin to keep updated.
A theme setting. Some themes, Divi for example, have a header field for the ID or tag. Nothing extra is installed, but tracking disappears if you change theme.

If you are weighing themes anyway, our guide on how to install a WordPress theme shows what changes when you switch.

Method 2: add the code yourself

This route gives you the raw Google tag on every page, with two ways to place it.

A code snippet plugin

One.com suggests WPCode. Install and activate it, go to Code Snippets, then Header & Footer, paste the full Google tag in the Header field and save. The snippet lives in the database, so it survives a theme change. It also helps if you later add other scripts, such as ad pixels.

A child theme

You create and activate a child theme, back up its functions.php file, then add a snippet that prints the tag through the wp_head hook. One.com advises doing this only if you are comfortable with PHP, since a mistake can break the site. Never paste the tag into the parent theme’s files: an update will erase it. If you are unsure what a child theme is, read what a WordPress child theme is and when to use one.

Method 3: Google Tag Manager

Tag Manager is the better fit when you expect to add more than analytics, such as conversion or ad tags. The setup, as One.com describes it, has more steps:

Create a web container in Google Tag Manager. Its ID starts with GTM-.
Install the GTM4WP plugin, then open Settings, then Google Tag Manager, and enter the container ID.
In Tag Manager, add a Google tag with your Measurement ID, set the trigger to Initialisation, save, then Submit and Publish.

The warning that matters: if you also use Site Kit, don’t send Google Analytics through both. The tag would load twice and may record duplicate data.

Which one should you choose?

Situation Best fit
Beginner, one site, no code Site Kit or GA Google Analytics
Want few plugins and a tag that survives theme changes WPCode
Comfortable with PHP Child theme snippet
Several marketing tags to manage Google Tag Manager with GTM4WP

Every extra plugin is one more thing to update and one more possible weak point. Our WordPress security checklist is a useful companion if you keep adding tools.

Check that it works

01

Open your site in a private window and visit a few pages.

02

Open the Realtime report in Google Analytics. It shows visits from the last 30 minutes, and Google says data collection can take up to 30 minutes to start.

03

Give other reports time. One.com says they can take 24 to 48 hours to fill.

04

If nothing shows, check that the ID matches the one in your data stream and that the plugin or snippet is active.

Heavy tracking scripts can also add weight to a page. If your site feels slower after adding tags, see the 7 causes of a slow WordPress site.

Consent and other options

One.com notes that in the UK, the statistics exception for analytics cookies comes with conditions. If you turned on data sharing with Google or linked Google Ads, it recommends asking visitors for consent. A plugin such as Complianz can hold Google Analytics back until they agree. Rules differ by country, so check what applies to your audience, and ask a legal adviser if you are unsure.

If Google Analytics feels like more than you need, there are lighter alternatives. We cover them in analytics tools beyond Google Analytics.

Related guides

Priya Nair

Priya Nair

Priya covers hosting, performance, security and backups. She reads changelogs and pricing pages so readers don't have to, and flags what changed since the last update.

Updated on December 3, 2026