Do you want to set up Google Analytics on your WordPress site?
Every website should have Google Analytics connected to get insights into their website’s performance, user behavior, and traffic patterns. This will help you grow your website and get results.
In this guide, I’ll walk you through the process of setting up Google Analytics in WordPress.
Here are the different methods I’ll cover:
- Add Google Analytics to WordPress with MonsterInsights
- Add Google Analytics to WordPress with WPCode
- Add Google Analytics to WordPress Theme
The first two methods use WordPress plugins and the last one is where you can do it manually, though I never recommend doing that as it’s prone to errors and risks.
What is Google Analytics used for?
In simple terms, Google Analytics is a tool that helps you understand how people interact with your website. It gives you information about things like how many people visit your site, where they come from, what they do on your site, and how long they stay.
You can also see which parts of your website are popular and which ones might need improvement.
Here’s a look at the Google Analytics dashboard:

This data is valuable because it helps you make informed decisions to improve your website, create content that your visitors like, optimize your site, and ultimately, make your online presence more effective.
Now setting up Google Analytics is a bit complicated, we’re not going to lie. The process involves copying and pasting a tracking ID into your website’s HTML code. Sometimes your web hosting provider will help you with this.
If you’re not familiar with coding or working with website backend files, this could be risky. Placing the tracking code in the wrong location or making mistakes in the code can lead to tracking issues or even break your website.
For these reasons, I recommend a safer method and that’s using a Google Analytics plugin. The best one out there to connect your WordPress website to is MonsterInsights.
With MonsterInsights, you don’t need to mess with complicated code. You can connect your website to Google Analytics in just a few clicks.
Once you’re connected, you get a user-friendly and easy-to-understand dashboard, making it simpler to see your website’s performance data.
What I love about this plugin is that it translates Google Analytics data into plain language, so you can quickly understand how your website is doing.
It also offers extra tools to help you track things like popular content, clicks, and conversions without needing to understand complex analytics terms.
If you’ve already read complicated tutorials with things like global site tag, Google tag manager, and child themes, we’re not going down that route. This method is an automated process so it omits all of that!
In this tutorial, I’ll show you how to set up Google Analytics using MonsterInsights first because it’s safer and easier.
I’ll also cover how to do it manually if you prefer to add it without a plugin. Let’s get started.
Add Google Analytics to WordPress with MonsterInsights
This is by far the easiest way to connect your site to Google Analytics. The plugin will handle all the technical issues for you so you never have to worry about breaking your site or making a mistake.
Now if you don’t already have a Google account, you need to sign up for one. Then you can create your Google Analytics account. I’ll show you how.
Step 1: Sign Up for Google Analytics
Open the Google Analytics website and click the Get started today button in the top right corner of the page.

Now, you can sign into your Google account and once done, click on the Start measuring button on the next screen.

You’ll need to enter an Account name for your Google Analytics account.

Now different data sharing settings will appear. Check the boxes you want here and then head to the Next step.
Now you’ll see options to add the property details of your website. This includes the site name, reporting time zone, and currency.

In the next step, enter in your business information such as the industry and the size of your company, and check all of the ways you plan to use Google Analytics for your business.

When you’re finished, click the Create button. In the popup window that appears, you can review and accept the terms of service.
Now, to create a data web stream for your WordPress website, click the Web button.

In the next step, enter your website’s URL and name.

After creating the property, you’ll receive a tracking code. This code is unique to your website and needs to be added to your WordPress site.
It would look like this: G-SV0GT32HNZ.

If you’re unable to find your GA4 Measurement ID, go to Admin » Property » Data Streams. Click on a data stream. You’ll see your Measurement ID in the stream details after the Stream URL and Stream Name.
Make a copy of these because you’ll need them later.
Now the hard part is done! You’ve created your Google Analytics account. All you have to do is sync it to your website.
Step 2: Install MonsterInsights
Log in to your WordPress dashboard and head over to to Plugins » Add New page.
Search for “MonsterInsights” and then you hit the Install Now button and activate the plugin.

Step 3: Connect to Google Analytics
MonsterInsights automatically launches a setup wizard that you can follow. The steps are super easy to understand so you won’t have any trouble here.
You can also access the same options under Insights » Settings to authenticate your blog with Google Analytics. Here, click the Connect MonsterInsights button.

Next, choose the Google account you want to connect to. It should be the same one you used to sign up for Google Analytics. You’ll also need to grant MonsterInsights the permissions it needs.
Then choose the correct website profile for your blog and click Complete Connection.

Now the plugin will authenticate your account and will redirect you back to the MonsterInsights setup page.
That’s it. Wasn’t that easy? Now, you can access your analytics right inside your WordPress dashboard any time you need. You’ll see readymade reports like this:

The metrics reports include:
- Overview
- Traffic
- Publishers
- Search Console
- eCommerce
- Dimensions
- Forms
- Realtime
- Site Speed
There’s a drop-down menu to customize the time period and filter data.
In the Publishers report, you’ll see top performing posts and pages along with pageviews, bounce rate, and sessions. If you scroll down a bit, you’ll find more sections like Interests and Scroll.

MonsterInsights is a really powerful plugin so I’ll walk you through its key features and settings you need to know about.
Step 4: Configure MonsterInsights Settings
By default, you’ll see the standard reports I mentioned in the previous section inside your WordPress dashboard. Aside from that, MonsterInsights makes it easy to create custom reports and configure advanced settings for your site. You can either add them through the launch wizard or in the plugin’s Settings tab.

Here are the main highlights you need to know about:
Affiliate Link Tracking – You can add affiliate link paths that you use to track how affiliate links are performing
Access to MonsterInsights Reports – Grant select users permission to view MonsterInsights reports
Automatic Plugin Updates – Enable or disable the option to install updates automatically.
Enhanced Link Attribution – The easiest way to see where users are clicking on your site
20+ Advanced Tracking – Include advanced stats on author tracking, form conversion tracking, scroll tracking, and more
All in One SEO Toolkit – The best WordPress SEO plugin that integrates with MonsterInsights
eCommerce Tracking – Track revenue and other eCommerce data
Advanced Growth Tools – Grow your site with a campaign URL builder, popular posts addon, and A/B testing integration
Privacy Compliance Addon – Helps Google Analytics become compliant with GDPR, CCPA, and more
Advanced Reports – Get access to advanced reports inside MonsterInsights, such as a real-time report, search keywords, publishers and eCommerce reports, and more
Here’s what these settings look like in the launch wizard:

It’s really as easy as selecting a button and saying yes! When you’re done selecting the recommended settings, you’ll see a success message that says ‘Awesome, You’re All Set!’
With that, you’ve successfully connected and configured a new Google Analytics property on your WordPress site.
Remember that the user interface and features of plugins can change over time. Always refer to the plugin’s documentation or support resources for the most up-to-date instructions.
Lastly, always be mindful of data privacy and compliance regulations when using analytics tools, especially if you’re collecting data from visitors in regions with strict privacy laws like the EU’s General Data Protection Regulation (GDPR).
Add Google Analytics to WordPress with WPCode
You can add the Google Analytics tracking code to your site’s header with the WPCode plugin (formerly Insert Headers and Footers).
First, you need to go to your Google Analytics account. In the Web Stream Installation section under the ‘Install manually’ tab, there’s a code available, like so:

Next, install and activate the WPCode plugin on your WordPress site.
Then, from the left WordPress menu, go to Code Snippets » Headers & Footers:

Now you can paste the tracking code into the Header box here.
Don’t forget to click the ‘Save Changes’ button to store your settings.
For more on how to use WPCode, follow our video tutorial course: WPCode 101 Course »
Add Google Analytics to WordPress Theme
You can manually add the code to your WordPress theme but if you’re not familiar with coding, I do not recommend this method.
Plus, if you switch or update your theme, you could lose your customizations. You’ll need to remember to add the tracking code every time you update the theme.
1. Add Code in header.php File
Access your website files using cPanel or FTP. Then, edit the header.php file in your WordPress theme.
Now you need to paste the Google Analytics tracking code that you copied earlier right after the <body> tag.
Don’t forget to save your changes or upload the file back to your server.
2. Add Code in functions.php File
Access your website files using cPanel or FTP and find the functions.php file. Then you can add this code below:
1 &amp;lt;?php
2 add_action('wp_footer', 'add_googleanalytics');
3 function add_googleanalytics() { ?&amp;gt;
4 // Paste your Google Analytics code here
5 &amp;lt;?php }
6 ?&amp;gt;
Make sure you replace ‘Paste your Google Analytics code here’ with your actual code. This method will automatically add the same tracking code to every page on your WordPress site.
With that, you’ve successfully added Google Analytics to your WordPress site.
FAQs on Google Analytics in WordPress
Below, I answer the most common questions users often ask us on Google Analytics in WordPress.
What is Google Analytics, and why is it important for my WordPress website?
Google Analytics is a web analytics service that tracks and reports website traffic. It’s crucial for understanding your site’s performance, user demographics, and how visitors find and interact with your content.
Can I track the performance of my WordPress site on search engines with Google Analytics?
Yes, Google Analytics provides data on how your site performs in search engine results, including the keywords people use to find your site.
Are there any other Google Analytics plugins other than MonsterInsights?
Yes, there are other options to the MonsterInsights plugin like ExactMetrics. Check out this guide: Best Analytics Solutions for WordPress.
Is there a free version of MonsterInsights?
Yes, MonsterInsights lets you connect your site to Google Analytics for free. To access the more advanced Pro features, you need to subscribe to their premium plugin.
What is Google Analytics 4 vs Universal Analytics?
Universal Analytics is the previous version of Google Analytics which is now retired. All users were migrated to the new and improved platform called Google Analytics 4. It tracks user interactions across websites, apps, and devices, providing a more complete view of user behavior. It’s designed to be privacy-friendly and offers better cross-platform tracking.
How to track WooCommerce data?
MonsterInsights is really the best solution to track WooCommerce analytics. You can quickly enable enhanced eCommerce tracking to get insights into customers, purchases, transactions, and more. Follow their step-by-step guide: How to Set Up WooCommerce Google Analytics.
Which is the Best Google Analytics Solution for beginners?
I recommend that beginners start with a Google Analytics plugin like MonsterInsights or ExactMetrics. It’s easy to connect Google Analytics to your site and you’ll get all your data right inside your WordPress dashboard. The Google Analytics reports are made to be easy for anyone to understand and get actionable insights from.’
What is Google Search Console?
Google Search Console (formerly known as Google Webmaster Tools) is a free web service provided by Google that helps website owners and webmasters monitor and maintain their site’s presence in Google’s search results. It offers various tools and reports that provide valuable insights into how Googlebot, Google’s web crawler, interacts with your website and how your site performs in Google’s search results.
If I have Google Analytics, should I also sign up for Google Search Console?
Yes, both platforms offer very different data and tools. You should also create a Google Search Console account.
What is Google Site Kit?
Site Kit by Google is a WordPress plugin. It helps you learn how people find and use your site, how to improve, and monetize your content, directly in your WordPress dashboard
What should I do if I encounter issues with my Google Analytics tracking info in WordPress?
If you encounter issues, check your tracking code placement, ensure it’s up-to-date, and verify your Google Analytics account settings. You can also check Google Analytics documentation or seek help from WordPress support forums or experts for troubleshooting. If you’re using a WordPress plugin like MonsterInsights, then you can connect with the support team.
Can I use Google Analytics with WordPress.com sites?
Google Analytics integration is available for WordPress.com sites on the Business plan or higher. For other plans, you may have limited options or use alternatives provided by WordPress.com.
Can I track social media marketing using Google Analytics in WordPress?
Yes, you can track the traffic generated from social media platforms and measure the impact of your social media marketing campaigns using Google Analytics. Here’s a helpful guide on that: How to Set up Google Analytics Social Media Tracking.
I hope you found this tutorial helpful. Up next, you may also want to see this guide on the Best SEO plugins to next your SEO game to the next level.
If you want to master SEO and boost your site’s performance, then you’ll want to check out our video course:
This 21-part course breaks down key concepts into easy-to-understand steps, empowering you to take action and witness a positive impact on your website’s performance.
You can start learning for free and then sign up for an All-Access Pass if it interests you. Plus, there’s a 14-day money back guarantee so you can enroll today with peace of mind!