The simplest way to add Google Analytics to WordPress
You connect Google Analytics to WordPress by installing a plugin that reads your Google Analytics account and places the tracking code on every page of your site. The most straightforward route is MonsterInsights or Google Site Kit by Google — both let you authenticate with your Google account once, then handle the code placement automatically. You do not need to touch any code yourself.
If you use Jetpack (which many WordPress sites already have), it includes built-in Google Analytics integration. If you prefer not to install another plugin, you can also paste the tracking code directly into your theme's header file, but this requires you to find the right location and re-paste it if your theme updates.
Before you start, you will need a Google account and a WordPress site you have admin access to. The whole process takes about ten minutes.
Key Takeaways
- Google Site Kit and MonsterInsights are the two most common plugins; both connect to your Google account and place tracking code automatically.
- You must create a Google Analytics property for your site first, then connect it through the plugin — the plugin does not create the property for you.
- After installation, wait 24 to 48 hours before checking your analytics dashboard, because Google takes time to collect and display the first data.
- If you switch plugins later, uninstall the old one first to avoid duplicate tracking codes, which will skew your visitor counts.
Setting up a Google Analytics property
Before you install a plugin, you need a Google Analytics property — a container that holds all the data from your site. Go to analytics.google.com, sign in with your Google account, and click "Create" or "Start measuring." Google will ask for your website name, URL, and time zone. Choose the time zone where you or your business operates, because all your reports will use that time.
Google will then show you a Measurement ID (it looks like G-XXXXXXXXXX). You do not need to copy this down — the plugin will find it automatically when you authenticate. But if you ever need to verify you are in the right property, this ID is how you check.
Once the property exists, you can move to WordPress and install the plugin. Google Analytics will not show any data until the tracking code is actually on your site.
Installing Google Site Kit (the official Google plugin)
Go to your WordPress dashboard, click "Plugins," then "Add New." Search for Google Site Kit (the author is Google). Click "Install Now," then "Activate."
After activation, you will see a "Site Kit" menu item in your WordPress sidebar. Click it, then click "Start setup." Google Site Kit will ask you to sign in with your Google account — use the same account you used to create the Analytics property. It will then ask permission to connect to your Google Analytics, Search Console, and other Google services. Click "Allow" to proceed.
Site Kit will automatically detect the Analytics property you created. If you have more than one, it will show a list and ask you to choose. Select the property for this WordPress site, then click "Connect." The tracking code is now on your site.
Installing MonsterInsights (the most popular third-party option)
Go to your WordPress dashboard, click "Plugins," then "Add New." Search for MonsterInsights (the free version is called MonsterInsights Lite). Click "Install Now," then "Activate."
After activation, a "MonsterInsights" menu will appear in your sidebar. Click it, then click "Connect MonsterInsights." You will be taken to a page that asks you to sign in with your Google account. Sign in, then click "Allow" when MonsterInsights asks for permission to access your Analytics property.
MonsterInsights will show you a list of Analytics properties on your account. Select the one for this WordPress site, then click "Confirm." The tracking code is now active. The free version shows basic reports inside WordPress; the paid version adds more detailed insights and recommendations.
Pasting the code manually if you prefer not to use a plugin
If you want to avoid installing a plugin, you can place the tracking code directly in your theme. Go to analytics.google.com, click the gear icon (Settings) in the bottom left, then click "Data streams." Click your website, and you will see a code block labeled "Global Site Tag (gtag.js)." Copy the entire code block.
In WordPress, go to "Appearance," then "Theme File Editor." Look for a file called header.php in the list on the right. Open it and find the closing </head> tag (usually near the bottom). Paste the Google code just before that closing tag, then click "Update File."
The downside of this method is that if your theme updates, the code may be overwritten. You would have to paste it again. Most people use a plugin instead to avoid this problem. If you do use this method, do not also install a plugin — you will end up with duplicate tracking codes.
Checking that the code is working
After you install the plugin or paste the code, go to your WordPress site's home page and load it in your browser. Then go back to Google Analytics and click "Real-time" in the left menu. Within a few seconds, you should see "1 active user now" or a similar message. This means the code is firing and Google is receiving data.
If you do not see an active user after 30 seconds, refresh your WordPress home page again and wait another 30 seconds. If you still see zero, check that you selected the correct Analytics property in the plugin, or that you pasted the code in the right place in header.php.
Do not worry if your main Analytics dashboard shows no data yet. Google takes 24 to 48 hours to process and display historical data. The real-time report is the fastest way to confirm the code is working on day one.
Switching plugins or removing duplicate tracking
If you installed one plugin (like MonsterInsights) and later want to switch to another (like Google Site Kit), uninstall the first plugin before activating the second. Go to "Plugins," find the old plugin, click "Deactivate," then click "Delete." This removes the old tracking code.
If you accidentally have two plugins active at the same time, or if you pasted code manually and also installed a plugin, you will have duplicate tracking codes. This causes Google Analytics to count each visitor twice, which makes your numbers meaningless. Check your site's page source (right-click, "View Page Source," then search for "gtag") to see how many times the code appears. If it appears more than once, remove the extra copies.
Once you have only one tracking code, your data will be accurate again. Google does not retroactively fix data from the period when you had duplicates, so it is worth catching this early.
Frequently Asked Questions
Do I need to install a plugin, or can I just use Google Analytics without one?
You can paste the code manually into your theme's header file, but a plugin is simpler because it handles code placement and updates automatically. If your theme updates, manual code can be overwritten. Most WordPress sites use a plugin for this reason.
What is the difference between Google Site Kit and MonsterInsights?
Google Site Kit is free and made by Google, but it only shows basic reports inside WordPress. MonsterInsights Lite is also free and shows more detailed insights. The paid version of MonsterInsights adds recommendations and advanced features. Both place the tracking code correctly; the choice is mainly about which dashboard you prefer to use.
Why does my analytics dashboard show no data after I install the plugin?
Google takes 24 to 48 hours to collect and display data. Check the real-time report first to confirm the code is working. If real-time shows active users, your data will appear in the main dashboard within a day or two. If real-time shows zero, the code may not be installed correctly.
Can I use Google Analytics if my WordPress site is on WordPress.com instead of self-hosted?
WordPress.com has its own built-in analytics, but you can also connect Google Analytics. Go to your WordPress.com dashboard, click "Settings," then "Traffic," and look for the Google Analytics section. You will need to authenticate with your Google account there instead of installing a plugin.
What happens to my data if I uninstall the plugin?
Your historical data stays in Google Analytics forever. Uninstalling the plugin just stops new data from being collected. If you reinstall the same plugin or a different one later, you can reconnect to the same Analytics property and continue collecting data from that point forward.