Do you want to install Google Analytics in WordPress? Knowing how your audience interacts with your website is crucial for your success. The best way to know your audience is through your traffic stats, and this is what Google Analytics provide for FREE. In this article, we will share why Google Analytics is important, and how you can install Google Analytics in your WordPress blog (step by step).

Why is Google Analytics Important for Bloggers?
Once you start a blog, your #1 goal is to get more traffic and subscribers. Google Analytics help you make data-driven decisions by showing you the stats that matter. You can see:
Who visits your website?
This part of analytics answers what is the geographical location of your audience, which browser did the user use to visit your site and many other important information such as: screen resolution, JavaScript support, Flash support, language and more.
This data is extremely useful, and it can help in numerous ways. When getting a custom design, you can use the user data to make sure that your site will be compatible with your audience.
If most of your users don’t have Flash support, then you should avoid adding flash element in your site. If most of your users are on 1280 screen resolutions, then make sure that your design is compatible with that resolution or smaller.
What do people do when they are on your website?
You can track where the user is going on your website, how long do they stay on your website, and what is the bounce rate (the percent of users exit your site on the first visit).
By using this information, you can decrease the bounce rate and increase your pageviews.
When do people visit your website?
By looking at the hottest hours in the day for your site, you can pick the time when you publish your post. If that time zone is not compatible with yours, then you can schedule your post to meet that hour.
How do people find your website?
This section of the analytics show you where did the user come from (for example: Search Engines, Direct Links, Referral links from another site).
It also shows you what percentage of your visitors came from each of these sources. Google analytics gives you the breakdown of each of these categories. If it is the search engine category, then it shows you which search engine got you the most traffic, Google, Yahoo, Bing etc.
The breakdown of referral sources show you which sites you need to work with the most. If your top referral source is Facebook, then you need to have exclusive Facebook content to make your Twitter audience feel special.
If your top referral source is an external website, then you might want to consider having a partnership with that website (guest post exchange or something else).
How do people interact with your content?
Google analytics shows how your users interact with your site’s content. It shows you what percent of the user clicked on which link on your site and much more.
You can run A/B split tests by creating content experiments in Google Analytics to understand what works best to meet your goals.
By seeing the user interactivity, you can work your content around your users. By seeing the answers to the questions above, you can focus on the strategies that work for your site and eliminate the strategies that don’t work.
Simply put, eliminate the guess work and focus on stats that matter, so you can make data driven-decisions.
Video Tutorial
If you don’t like the video or need more instructions, then continue reading.
How to Signup with Google Analytics
Step 1: First you need to create a Google Analytics account. To do this, visit Google Analytics Signup Page.
You will see a screen like the one below. If you already have a Google or Gmail account, then you can use that to sign-in. If you do not have a Gmail account, then you would have to create an account for yourself.

Step 2: Once you sign-in with your Gmail account, you will be prompted to a screen like the one below. This is where you will signup for Google analytics with your Gmail account.

Step 3: On the next screen, you will be given choice to choose between a website or mobile app. Make sure you select website.
After that you need to enter account name (It will be the Google Analytics profile name for this website), Website name, website’s URL, country, and the time zone.

Once you have entered this information, click on the Get Tracking ID button. You will be presented with Google Analytics terms and service which you must agree to, so click on I Agree button.
Step 4: Now you will be presented with your Google Analytics tracking code. You can copy this tracking code because you will need to enter it in your WordPress site depending on the method you use below.
![]()
We suggest leaving the analytics browser tab open as you may need to revisit it, once you have installed the code on your WordPress site.
Now that you have setup a Google Analytics account, lets take a look at how to install Google Analytics in WordPress.
How to Install Google Analytics in WordPress
There are many different ways to setup Google Analytics in WordPress. We will show you three different methods where the first option is the easiest and the last being the hardest.
You can choose the one that best suits your needs.
1. Google Analytics for WordPress by MonsterInsights
MonsterInsights is the most popular Google Analytics plugin for WordPress. Over 1 million websites use it including the likes of Bloomberg, PlayStation, Zillow, and more.
It is the easiest and by far the best way to add Google Analytics to WordPress (for all users beginners and experts).
MonsterInsights has both a free version and the Pro version. In this tutorial, we will be using the MonsterInsights free version.
You can use the MonsterInsights Pro version if you want more advanced features like Ecommerce tracking, Ads tracking, Author tracking, etc. The process of setting them up is the same.
Let’s get started.
The 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 labeled ‘Insights’ to your WordPress admin menu. You need to visit Insights » Settings to configure the plugin settings.
On this screen, you need to click on ‘Authenticate with your Google account’ button to connect Google Analytics with your WordPress site.

This will bring up a popup where you will be able to authenticate with your Google Account.

Click on ‘Next’ to continue.
Now you need to click on ‘Click to get Google code’ button.
This will bring up another popup with the message ‘MonsterInsights would like access to your Google Analytics data’.
Click on the ‘Allow’ button to continue.

The authentication popup will now show you a line of code which you need to copy.

Next, you need to enter this code in the MonsterInsights popup and then click on ‘Next’ to continue.

The final step is to select the profile you want to track. You need to select your website here and then click on the next button to continue.

That’s all you have successfully installed and setup Google Analytics on your WordPress site.
Remember, it will take Google Analytics sometime before showing your stats.
The best part about MonsterInsights is that you can view your Google Analytics report inside your WordPress dashboard. Simply visit Insights » Reports page to checkout a quick overview of your analytics data.

You can go also go in the Tracking tab to customize the tracking settings based on your needs:
![]()
Note: MonsterInsights was formerly known as Google Analytics for WordPress by Yoast. WPBeginner’s founder, Syed Balkhi, acquired the plugin in 2016 and rebranded it to MonsterInsights. Now it is part of our family of premium WordPress plugins.
2. Insert Headers and Footers Plugin
This method is not as not as good as MonsterInsights because you will not be able to do advanced tracking configuration, and you will not be able to view Google Analytics data in your WordPress dashboard.
First, you need to install and activate the Insert Headers and Footers plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to visit Settings » Insert Headers and Footers page. Here you need to paste the Google Analytics code that you copied in step 4 into the headers section.

Don’t forget to click on the save changes button to store your settings.
3. Install Google Analytics in WordPress Theme
This method is for advanced users only who are familiar with code. It is somewhat unreliable because your code will disappear if you switch or update the theme. We almost never recommend using this method.
If this is your first time adding code to your WordPress files, then you should check out our guide on how to copy paste code snippets in WordPress.
Add code in header.php file
Simply edit the header.php file in your WordPress theme and paste the code you copied in step 4 right after the <body> tag.
Don’t forget to save your changes and upload the file back to your server.
Add via Functions File
You can also add Google Analytics tracking code to WordPress functions file. It will then automatically add code to every page on your WordPress site.
You will 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 code from Step 4 here
<?php } ?>
Viewing Reports on Google Analytics Website
Google Analytics is capable of showing you a treasure of data collected from your stats. You can view this data by visiting your Google Analytics dashboard and clicking on the reporting tab.

You will see the built-in Google Analytics reports in the left column. Each section is divided into different tabs and clicking on a tab will expand it to show more options.
- Audience tab will show reports to help you understand your users.
- Acquisition reports explore where your users came from.
- Behavior reports summarize what your users do after they arrive on your site.
- Conversion reports show how well you’re doing against your goals.
We hope this article helped you learn how to install Google Analytics in WordPress. You may also want to see our ultimate WordPress SEO guide for beginners.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Doesn’t work because I have a free wordpress.com blogsite. So not possible to add plugins. So disappointed

If you have any advice for me. Please let me know
Does monsterinsights reduce page loading speed?
Hi,
I just upgraded to the business plan so i could install monster insights but as some others have written when I go to put in the code it says BAD CODE. When I go back to the beginning and login to my google account and click Get Code and go through the steps it just returns to the original screen.
What should i do guys?
Hi Simon,
We recommend using self hosted WordPress. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
You can also reach out MonsterInsights support team for help as well.
Can I paste the code into function.php of child theme?
Yes, you can.
Thanks for the great guide! On the Google Analytics page where the tracking ID appears, it also has the Universal Analytics Tracking Code and says:
To get all the benefits of Universal Analytics for this property, copy and paste this code into every web page that you want to track.
Do I need to do this, or does MonsterInsights take care of tracking each page on my website? (I didn’t need to enter the Tracking ID from this page, as MonsterInsights found it).
Thanks!
Hi Anna,
Once you have installed MonsterInsights, it will take care of tracking all pages on your WordPress site.
Do you need to have WordPress.org for this or can I still use it with WordPress.com?
Hey Erin,
You cannot use Google Analytics on WordPress.com unless you upgrade to their business plan. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
It would be really great if you had said that at the beginning. Do you know how many places I’ve looked for how to do this and not one of them mention you have to have the business plan and not be on .com but on .org.
Thanks a ton for saving tremendous man hours through your guidance….. This article especially helped me in setting up analytics for my blog in less than 30 mins (that includes reading,setting up, testing on WP&GA)
Hi, I have a few different views for my analytics. Say I have activated View 1 for Monster Insight, does all the views in Google Analytics still runs?
Great stuff. One way would have been ok. Three are even greater. Thanks!
Thank you. You were very helpful!
Thanks, that was really helpful & easy.
Hi, I’ve followed all your instructions for the monster insights steps, but when I get the code, it keeps saying bad code, or ensure your account is signed up for analytics. I think it all is, I’ve authenticated it? Are you able to help? I don’t know what else to try!
Hey Kate,
Please make sure that you are using the same Google account that you used to sign up for analytics. You can signout of your Google account, and then sign back in to make sure that you are using the same Google account.
Also go to your Google Analytics dashboard and see if you can see your website profile there.
In a switch to self hosting that has been so difficult, THIS was so helpful, and so simple to perform myself!
Great tutorial with easy to follow step by step details.
I used this to set up Google Analytics on my blog using the free Monsterinsights plugin recommended in method one.
It took me about six minutes, and that included reading through the tutorial steps one at a time as I completed each one.
Many thanks!
Hey Paul,
Thanks, we are glad that you found the article helpful. You may also want to subscribe to our YouTube Channel for WordPress video tutorials.
Finally what I been looking for! Thank you
Oddball question…but would it be possible to manually install Google Analytics (via headers theme & functions.php file) AND use a Monster Insights plugin? Assuming the same Google account tracking ID/code is used.
It’s not necessarily something we would do, just wanted to answer a client’s question.
(hope this makes sense)
Thank you,
Rex
Hey Rex,
No it will cause double tracking issue.
Ah, now that’s interesting…
Also, thanks for the tutorial. Very helpful!
I tried the third way and did everything as instructed. After completing everything, my google analytics dashboard does not show any data. Can somebody help me with more details. The website was developed in WordPress and i do not want to use the first method with plugin.
I tried this also and it doesn’t show any data either. However, on Activate it shows that my analytics are working and show my monthly users and unique users. Why am I not seeing any of this in Google Analytics?
THANK YOU! It’s really nice when someone takes the time to make a complicated process seam easy.
Thanks for this very informative post
Thanks for this! I was starting to feel a bit overwhelmed, but this article made it super easy.
Thank you so much for this article. I had a feeling it was going to be a plugin. Used to use Dreamweaver which had great ways to do SEO, but not so great with everything else. I’ll make sure to follow for other great insight.
Thanks this post was easy to follow and the links were really useful. I’m sure it saved me a lot of time getting analytics set up on a couple of new websites. Many thanks!
When I try to set up in WordPress this works great until I get to adding the Authentication code. When I enter it, it either tells me “Bad Cod” or “Connection Error.” My host is Godaddy.
Thank you!
Massively grateful for the ‘insights’ (ba dum ching!) you’ve provided here. Sorry about the pun. I’m just happy to finally be able to have a play with analytics. Thank you.
It was a very detailed step by step explanation..Was helpful ..
You got a awesome theme, it’s very light loved it.
Thanks,
Navin Rao
Excellent tutorial. I have been trying to use Google Analytics and this post of yours was very helpful.
Regards
(Barnali)
This was very helpful. Thanks for sharing!
I entered in the code and it changed the color scheme of my entire page. I deleted the code and it went back to its original state. Why is this happening?
Hi,
Thanks, using Monsterinsights was easy. However, the google analytics code appears on all my pages in the upper left side. How do I hide the google analytics code from website?
Tank you.
Hi Rob,
Try switching to a default WordPress theme like (Twenty Seventeen). It this resolves your issue, then most likely your WordPress theme is not using wp_head function which is required by WordPress.
love this lesson. thanks
I did the easiest method and have the plug in on my wordpress ran site. To be clear if I did this method and followed all the steps I should start tracking immediately although results won’t show for a while. I did not ever copy and paste the universal tracking code anywhere but that was not in any steps that I saw. So if I did the steps it should work?
Thanks
This was a very helpful article! Thank you very much!
Very helpful article thank you! Exactly what I needed to know!
1) I tried to put the code in my functions.php file and did not really pay attention. It did not work. On closer inspection, it is not really clear what I should be pasting and what is just there to help locate the code. Also, it is backwards (add action vs function) from my other code setting up my child theme. As a newbie to pho I do not know if this matters. Anyway, moved on
2) I am now using my theme >Theme Options>Custom Code>Footer Code and inserted the Google script direct into this. Is this okay without all the doings of all the plug ins?
Thanks
In regard to the step where you “select profile”, the analytics profile that is, mine says “select a profile”. However, there is no profile to choose from. Any idea why?
Shawn
Hey Shawn,
This issue was caused by certain WordPress themes and plugins, it has been resolved in the latest version of MontserInsights. Please update your plugin. Let us know if you come across any issue.
This was a great tutorial and so easy. Thank you for sharing!!
Performance impact of installing this?
Hi,
It is a very helpfull article, but I have a problem. When I reach the point where I’m supposed to select a google analytics profile, there aren’t any options to choose. I have created a google analytics profile by following the steps you show, so I don’t know why it doesn’t show up. Do you have any idea why it doesn’t work?
Hi Simone,
Make sure you are logged in with the same Google/Gmail account that you used to create your Google Analytics profile. Next, you can visit your Google Analytics dashboard to make sure that your website profile is there.
Hi! I’ve got the same problem! And I am logged in with the same google account + the google analytics dashboard shows my profile so there is no issue there. I’ve tried it two times already and it’s always at that last step that there is no profile to select…
Hi,
There is an update available for MonsterInsights which should address this issue.
Very informative!
This is what a new bee of wordpress expects to know.
Good article! Will share for the needy
Thank you very much for this article! I always find you articles very helpful. Still, I didn’t find the report tab.
Hi. I am using WP v4.7.2 and my theme is Traffica.
I have loaded the code in the footer section as suggested and replaced the text with my GA code. When I update and reload my web page, all I see is the GA code. Please can you advise where I am going wrong?
If you install this in the “insert header footer” plug-in and save, will that apply tracking to EVERY page on the site? So it will track data from every page? Thank you!
Yes it will track data from every page.
I have been looking for this tutorial.very nice explained. Thank you
Thanks for this tutorial!
Hi. Thank you for the tutorial. I think I set up my analytics correctly. How long does it take to track data? And how can I tell if I set it up correctly?
Thank very much after reading your post about wordpress blogging I started and it is moving and working well Thanks..
Hi Chima,
Glad to hear that
Don’t forget to follow us on Facebook for more WordPress tips and tutorials.
Thank you for this wonderful tutorial.
Thank you so much for this tutorial! It was simple and easy to follow, and I now have google analytics set up. So glad I found this website!
Hi Kristel,
We are glad you found it helpful. You may also want to subscribe to our YouTube Channel for WordPress video tutorials.
Hi, thanks for the helpful info!
I’ve added the code snippet in header section, now that i need to modify the code for each page for GA remarketing purpose, how can i do that?
thanks you very much, this really help me to set my analytics