Many successful website owners probably remember the first time they browsed their WordPress website and wondered if anyone actually read its content.
In the beginning, we often don’t know how to track visitors or understand their behavior. This is where tools like Google Analytics come in handy.
Understanding how users interact with your content is key to growing your website. Maybe you want to build a loyal readership, increase sales, or become an authority in your field.
Whatever your goals are, website traffic data can help you achieve them. It can help you understand what’s working, what’s not, and where you can improve.
Over the years, we’ve helped countless website owners install Google Analytics on their WordPress sites. Even today, it remains the best way to understand your audience and make smarter decisions.
In this guide, we’ll walk you through the steps to install Google Analytics in WordPress. We’ve taken care of most of the tedious preparation so you can get set up with ease. 🚀
First, we’ll explain why Google Analytics is important and how it can help you grow your website.
After that, we will show you how to sign up for a Google Analytics account and different ways to install it on your WordPress site.
Finally, we'll explain how to view your traffic reports in Google Analytics.
Here is a brief overview of what you will learn in this article:
- Why is Google Analytics important for bloggers?
- How to Sign Up for Google Analytics
- How to Install Google Analytics in WordPress
- Method 1: WordPress Google Analytics by MonsterInsights
- Method 2: Install Google Analytics in WordPress using WPCode
- Method 3: Install Google Analytics in WordPress Theme
- View reports in Google Analytics
- Getting the most out of Google Analytics
Are you ready? Let’s get started!
Why is Google Analytics important for bloggers?
Once you start a blog, your first goal is to get more traffic and subscribers. Google Analytics helps you make data-driven decisions by showing you important statistics. You can see:
Who visits your website?
This section of analytics shows the geographic location of your audience, the browsers people use to access your site, and other important information such as screen resolution, JavaScript support, Flash support, language, and more.
This data is extremely useful and can provide many benefits. When creating a custom website design, you can use user data to ensure that your website meets the needs of your audience.
If most of your users don't support Flash, avoid adding Flash elements to your site. If most of your users use a 1280 screen resolution, make sure your design is compatible with that resolution or lower.
What do people do when they visit your website?
You can track where users go on your site, how long they stay on your site, and your bounce rate (the percentage of users who exit your site on their first visit).
Use this information to reduce your bounce rate and increase your page views.
You can also find the most popular articles, underperforming articles, and the types of content users are looking for.
When do people visit your website?
By looking at the time of day when your site is most popular, you can choose the best time to post. If that time zone is not compatible with yours, then you can schedule your post during that time.
How do people find your website?
This part of analytics will show you where your users are coming from. For example, did they use a search engine, type in a direct link, or click on a referral link from another website?
It will also show you the percentage of visitors coming from each source. Google Analytics will provide a breakdown of each category. In the case of the search engine category, it will show you which search engine is sending you the most traffic, such as Google, Yahoo, Bing, etc.
Segmenting referral sources can help you understand which sites you need to work with the most. If your top referral source is Facebook, then you need Facebook-exclusive content to make your audience feel special.
If your primary referral source is an external website, then you may want to consider forming a partnership with that site (guest post exchange or otherwise).
How do people interact with your content?
Google Analytics shows you how users interact with your website content. It shows you what percentage of users clicked on which link on your website, etc.
You can run A/B split tests by creating content experiments in Google Analytics to see which approach best achieves your goals.
By observing user interactions, you can design content around them. By knowing the answers to the above questions, you can focus on the strategies that work for your site and avoid ineffective approaches.
In short, eliminate the guesswork and focus on the statistics that matter so you can make data-driven decisions.
How to Sign Up for Google Analytics
Google Analytics is free to use and all you need to sign up is a Google or Gmail account. The sign-up process is very simple. Simply follow the step-by-step instructions below to create your Google Analytics account.
Step 1: First, you need to visit the Google Analytics website to sign up. Once you are on the website, just click on the ‘Get Started Now’ button.
Next, you will be asked to sign in with your Google Account.
If you already have a Google or Gmail account, you can use it to sign in. Otherwise, you can go ahead and create a Google Account for yourself.
Step 2: After logging in with your Gmail account, you will see the welcome screen as shown below.
You need to sign up for Google Analytics using your Gmail account here. Click on the “Start Measuring” button.
Afterwards, you will be asked to provide an account name.
This name will be used internally, so you can use any name, such as your company name.
Google Analytics will also display multiple account data sharing settings.
These settings allow you to control the sharing of your Google Analytics data. You can keep the default settings and proceed to the next step.
Step 3: On the next screen, you need to create your Google Analytics property.
Google has launched a new version of Analytics called Google Analytics 4 or GA4. It's the latest version that tracks your website and mobile apps in the same account. In addition, you get new features, metrics, and a different reporting interface.
Go ahead and enter the hotel name and select the reporting time zone and currency. Then click the "Next" button.
On the next screen, you need to select an ‘Industry Category’ from the website’s drop-down menu and select ‘Business Size’ from the given options.
Once you are done, just click on the Next button.
Next, you need to select your business goals and choose how you want to use Google Analytics in your business. This will help you get personalized business reports.
For example, there are options for generating leads, driving online sales, increasing brand awareness, examining user behavior, and more.
You can select multiple options or select all of the options that suit your needs. We recommend that you select the "Get Benchmark Report" option, which will populate all of the Google Analytics reports in your account.
Once you are done, just click on the Create button.
Step 4: Now you will see your Google Analytics Webs flow options.
Since we’re setting up Google Analytics for a WordPress site, go ahead and select “Web” as the platform.
After that, you need to enter your website URL and stream name.
By default, Google Analytics has the Enhanced Measurement option enabled. This allows you to track data such as page views, scrolls, outbound clicks, file downloads, etc. in Google Analytics.
📝 NOTE: If you plan to use the MonsterInsights plugin, you should turn off the Enhanced Measurement option. Otherwise, the plugin will collect and display twice the amount of data.
Next, you can click on the “Create Flow” button.
You can now see your stream name, URL, ID, and measurement ID.
It will also display the different enhancement measurements it recorded.
At the top, you will also see an alert bar which will show you how to add Google Analytics to your WordPress site.
Go ahead and click on the ‘See Tag Instructions’ button. You should now be able to see the different ways to add the Google Analytics tracking code to your WordPress site.
Next, you can switch to the Manual Installation tab.
You will then see the Google Analytics tracking code.
Please copy this tracking code as you will need to enter it into your WordPress site in the instructions below. You can also keep this browser tab open and switch back to copy the code when needed.
We recommend that you keep your Analytics browser tab open. This is because you may need to revisit it after installing the code on your WordPress site.
Now that you have your Google Analytics account set up, let’s take a look at how to install Google Analytics in WordPress.
How to Install Google Analytics in WordPress
There are a few different ways to set up Google Analytics in WordPress. We’ll show you three methods, with the first being the easiest and the last being the hardest.
You can choose the one that best suits your needs.
💡 Pro Tip: You only need to use one of these methods on your website to avoid duplicate tracking of page views in your Google Analytics account.
Method 1: WordPress Google Analytics by MonsterInsights
MonsterInsights is the most popular Google Analytics plugin for WordPress . It is used by over 3 million websites including Bloomberg, PlayStation, Zillow, WPBeginner, and more.
This is by far the easiest and best way to add Google Analytics to WordPress (for all users, beginners and experts alike). MonsterInsights offers both a paid premium plugin and a free version .
At SidelinePlay, we use MonsterInsights for a variety of tracking tasks, such as form submissions, CTA button clicks, and referral link performance. Read our full MonsterInsights review to learn why it’s so great.
For this tutorial, we will be using the free version of MonsterInsights.
If you want more advanced features like eCommerce tracking, ad tracking, author tracking, etc., you can use the MonsterInsights Pro version . The setup process is the same.
Let’s get started.
First thing you need to do is install and activate the MonsterInsights plugin. For more details, see our step by step guide on how to install a WordPress plugin .
Upon activation, the plugin will add a new menu item called “Insights” to your WordPress admin menu and you’ll see a welcome screen. Go ahead and click on the “Start the Wizard” button.
Clicking it will open the MonsterInsights installation wizard.
First, you need to select the category of your website (Business Website, Blog or Online Store). After selecting, click on the "Save and Continue" button.
Next, you need to connect MonsterInsights with your WordPress website.
Just click on the Connect MonsterInsights button.
This will take you to Google Accounts where you will be asked to sign in or select a Google Account if you are already logged in.
Continue to select your Google Account or enter your email to log in.
Next, you’ll be asked to allow MonsterInsights to access your Google Analytics account.
Click the Allow button to continue.
The next step to complete the connection is to select the profile you want to track.
You need to select your website here and then click on the Finish Connection button to continue.
After that, just click on the ‘Finish Connect’ button to continue. MonsterInsights will now install Google Analytics on your website.
Next, you'll be asked to choose the recommended settings for your website.
The default settings are suitable for most websites. If you use an affiliate link plugin, you will need to add a path for cloaking your affiliate links . This will allow you to track your affiliate links in Google Analytics .
MonsterInsights will also ask who can view the report. You can choose from different WordPress user roles.
Once you are done, just click on the ‘Save and Continue’ button to save your settings.
Next, MonsterInsights will show you a list of website tracking features you want to enable.
You can scroll down and click on the Continue button or the Skip for now option.
On the next screen, MonsterInsights will show that you have successfully set up Google Analytics tracking.
You can see that Google Analytics is connected, the tracking code is installed, and data is being collected.
Next, you can scroll down and see a field to enter your license key.
Go ahead and click on the “Complete the installation without upgrading” option for now.
You have successfully added Google Analytics to your WordPress website.
Disable Enhanced Measurement in Google Analytics
Now, if you created the data flow yourself in GA4 instead of having MonsterInsights create it, then you need to turn off Enhanced Measurement.
This is because MonsterInsights adds several custom Enhanced Tracking features. Enabling the Enhanced Measurement option can skew your data and display inaccurate results.
First, you can head to the Google Analytics tab or window in your browser. From here, click on the “Administrator” settings option in the bottom left corner.
Once you are on the Admin page, you will see different settings.
Just click on the Data Stream option.
Next, you will see your data flow.
Simply select the data stream you connected with MonsterInsights.
On the next screen, you need to disable the Enhanced Measurement option.
To do this, just click the toggle button.
Next, a pop-up window will open to confirm that you want to turn off Enhanced Measurement.
Go ahead and click on the Close button.
Changing data retention settings in Google Analytics
By default, Google Analytics sets data retention to 2 months. However, you can change this setting to use your data in custom reports after 2 months.
First, you need to go to Admin » Data Settings » Data Retention in Google Analytics .
Next, you can click on the “Event Data Retention” drop-down menu.
From here, simply select the “14 Months” option and click on the “Save” button.
Keep in mind that it takes some time for Google Analytics to display your statistics.
💡Pro Tip: Google Analytics allows you to extend your data retention period up to 14 months, but even if you choose the default 2-month option, privacy regulations like GDPR still apply.
Therefore, you still need to obtain user consent before tracking, and it is best to mention how long you retain the data in your privacy policy.
Not sure where to get started? Check out our guide on how to add a GDPR/CCPA compliant cookie popup in WordPress .
View Google Analytics reports in your WordPress dashboard
The best thing about MonsterInsights is that you can view your Google Analytics reports right inside your WordPress dashboard.
Simply visit the Insights » Reports page to get a quick overview of your analytics data.
You can also add annotations directly to MonsterInsights reports to record key changes you make to your website.
For example, you can add a note when you publish a new blog post, add a new landing page , etc. This makes it easy to track how these events affect your traffic.
With the new Conversations AI feature, you can even ask MonsterInsights for website stats that interest you.
For example, if you have an e-commerce site, you could ask how much revenue you made from a certain product during a specific time period.
This is much easier than searching through reports to find the data you need, especially when you are just starting out in analysis.
Additionally, MonsterInsights comes with a Popular Posts plugin that allows you to showcase your best-performing content to boost traffic and page views.
You can use it to automatically add inline popular post links to boost engagement.
If you’re running an online store, it can also automatically add your best performing products at the end of each blog post to boost sales:
If you run a WordPress blog, then the Page Insights plugin will be very useful.
Once installed, it will automatically add your blog stats to your All Posts screen, front-end (when logged in), and content editor screen.
Method 2: Install Google Analytics in WordPress using WPCode
In this method, we will show you how to manually install Google Analytics in WordPress. We will use WPCode to add the GA4 tracking code to your website’s header.
⚠️ Before we get started, please note that this method isn’t as good as MonsterInsights because you can’t do advanced tracking configuration. Also, you can’t view Google Analytics data in your WordPress dashboard.
The WPCode plugin allows you to safely add custom code snippets to your WordPress site without editing your theme files.
Some of our business partners use WPCode to manage tracking scripts, custom features, and other advanced settings, and it has been working great.
First, you need to copy the Google Analytics tracking code (global site tag) that you copied in step 4 when you created your Google Analytics account earlier.
The interface may look like this:
Next, you need to install and activate the WPCode plugin. For more details, see our step by step guide on WordPress plugin installation .
📝Note : You can use the free WPCode plugin to install the Google Analytics tracking code.
But upgrading to WPCode Pro unlocks even more powerful features — like full revision history to help you track changes and code scheduling to automatically enable or disable code snippets at specific times.
Upon activation, you need to visit Code Snippets » Header & Footer page. Here, you have to paste the Google Analytics tracking code that you had copied earlier in the Header section.
Don’t forget to click on the ‘Save Changes’ button to store your settings.
That’s it, you have successfully installed Google Analytics on your website.
Method 3: Install Google Analytics in WordPress Theme
This method is for advanced users who are familiar with the code. This method is less reliable because if you switch or update themes, your code will be gone.
We almost never recommend using this approach.
If this is your first time adding code to WordPress files, then you should check out our guide on how to copy and paste code snippets in WordPress .
First, you need to copy the Google Analytics tracking code that you copied earlier in step 4. You can find it in the Web Stream Installation section under the Manual Installation tab.
Now, there are two common ways to add this code to your WordPress theme files. You can choose one or the other (but not both).
1. Add code in header.php file
Simply edit the header.php file in your WordPress theme and paste the Google Analytics tracking code you copied earlier <body>
after the tag.
Don’t forget to save your changes and upload the file back to your server.
2. Add through function file
You can also add the Google Analytics tracking code to your WordPress functions file. It will automatically add the tracking code to every page of your WordPress website.
You need to add this code to your theme’s functions.php file.
<?php add_action('wp_head', 'wpb_add_googleanalytics'); function wpb_add_googleanalytics() { ?>
// Paste your Google Analytics tracking code from Step 4 here
<?php } ?>`
Don't forget to replace the "Paste the Google Analytics tracking code from step 4 here" portion of the above code snippet with your Google Analytics code.
View reports in Google Analytics
Google Analytics can show you a wealth of data collected from your statistics. You can view this data by visiting the Google Analytics dashboard.
You will see built-in Google Analytics reports in the left column. Each section is divided into different tabs, and clicking on a tab will expand it and show more options.
Google Analytics 4 reports are slightly different from the previous Universal Analytics reports. In the left column, you will see a dedicated reporting option. The reports are divided into two major categories, namely "Lifetime" and "User".
One of the most notable changes in GA4 reporting is the removal of the bounce rate metric. Apart from this, you will also find a new reporting interface, new metrics like engagement time, no goals in GA4, and more.
Here’s a breakdown of the different reports in Google Analytics 4:
- Real-time reporting is similar to Universal Analytics and shows active users on your site in real time.
- Acquisition reports show you which medium people used to find your website, such as organic search, referral, email, and affiliate marketing.
- The Engagement reports show conversions and events that occurred on your website.
- Monetization reports show all your e-commerce data in one place, with new reports like In-App Purchases and Publisher Ads.
- The retention report mainly shows the situation of new visitors and returning visitors, and helps you understand user retention.
- The Demographics report helps you view website traffic by major countries, cities, etc. It also displays gender distribution and interest reports.
- Technology reports show which devices, browsers, operating systems, app versions, and screen sizes people use most often to view your site.
Getting the most out of Google Analytics
Google Analytics is an extremely powerful tool with many great features. Some of them are obvious and easy to use, while others require a little extra setup.
Google Analytics works best with Google Search Console (formerly Google Webmaster Tools). It lets you see how your site performs in search results. See our complete guide to Google Search Console to learn how to use it to grow your site.
If you want to improve your WordPress SEO ranking and get more traffic, then we recommend you to use AIOSEO plugin for WordPress , which is an all-in-one SEO toolkit.
You can also use the free version of AIOSEO.
This plugin will help you fully optimize your WordPress website with proper schema markup, sitemaps, and everything you need to improve your SEO rankings.
I hope this article helped you learn how to install Google Analytics in WordPress.
If you liked this article, you can also share it on Twitter and Facebook.
Disclosure: Some of the links in this article contain affiliate links, which means we may earn a commission if you click through to visit us, at no extra cost to you. See how SidelinePlay is funded, why it’s important, and how you can support us.
Was this helpful?