How To Install Google Analytics In WordPress

Last Updated on June 4, 2021

Are you looking to install Google Analytics in WordPress? This post goes through the process step by step on how to install Google Analytics in WordPress making it easy even if you are a newbie or non-techie.

Google Analytics is important for your website because it allows you to know how your audience interacts with your site. One of the best ways to get to know your audience and the way they interact with your website is through your traffic stats. The best part is Google Analytics is free. In this post, we show you how to install Google Analytics in WordPress quick and easy.

Pin Image To Pinterest



Why Google Analytics Is So Important For Bloggers

Before I go into detail on installing Google Analytics in your WordPress site, I want to go over why Google Analytics is so important for your blog. Once you start a blog, the #1 thing you need to do is get traffic to your site and build your subscriber base via an email list. The reason Google Analytics is so important is that it will help you make decisions based on data by getting the stats that matter most to your site. Google Analytics allows you to see data such as:

Who is visiting your website?

This part of analytics provides you with the geographical location of your audience, which browser users are using to visit your site, the screen resolution the user is using, JavaScript support, Flash support, the user’s language, and much more. If you are like me, you are probably thinking wow! All of this data is going to be so useful and can help me in a variety of ways. When the time comes to get a custom design for your site you can use all of the user data to make sure site is designed and developed to be in tune with your site audience.

A good example of this is if you notice that a majority of your users don’t have Flash support, then you want to avoid adding flash elements in your site. Another example is if you notice most of your users are using 1280 screen resolutions, then you definitely want to make sure your design is going to be compatible with that resolution or smaller.

What do users do when they are on your website?

Another important thing you can track in analytics is tracking where the user is going to your website, how long do they stay on your site, and what is the bounce rate (the percent of users exit your site on the first visit).

By taking this information, you will be able to decrease the bounce rate of your site and increase your site’s page views.

When are users visiting your website?

An excellent way to use this data is to take a look at the hours in the day that you are getting the most traffic to your site. By analyzing this data, you will be able to choose the best time to publish your post. If for some reason that time zone is not compatible with your time zone, then you can schedule your post so that your post gets published at that time.

How are users finding your website?

This is a highly important part of analytics that you want to pay high attention too. In this part of analytics, it’s going to show you where the user came from. For example, (Search Engines, Direct Links and Referral links from another site).

It is also going to show you what percent of your site visitors came from these sources. The cool thing about Google Analytics is that it is going to actually give you the breakdown of these categories. So if it is the search engine category, then it is going to show you which search engine brought you the most traffic to your site such as, Google, Bing, Yahoo, MSN, AOL, etc.

For the breakdown of referral sources, it is going to show you which sites you should and really need to work with most. For example, if your top referral source is Twitter, then you need to make exclusive Twitter content so that your Facebook audience feels special. Another example is if your top referral source is an external website, then I’d highly recommend having some sort of partnership with that particular website. For example, guest post exchanging or something else creative that you come up with.

How do users interact with your site’s content?

Another great feature of Google Analytics is that it shows you how your users interact with the content of your site. For example, it will show you what percent of users clicked on which link and much more. This makes it easy to see what links users are going too.

A good thing to do is to create content experiments in analytics and run split tests to see what works best to meet your goals for your site.

By creating content experiments and running split tests, you can easily see the user interactivity so that you can create your content around your users visiting your site. Through time and testing, you will be able to focus on the strategies that work for your site and get rid of the strategies that aren’t working.

By doing this, you get rid of the guessing and can focus on actual stats that matter.

How to Sign up with Google Analytics

Step 1: The first thing you want to do is create a Google Analytics account. You can easily do this by simply going to the Google Analytics Signup Page.

When you arrive at the signup page, you will see a page shown like the one below. If you happen to have a Google or Gmail account already then you will just use that account to sign-in. If you don’t have a Google or Gmail account, then you want to create an account for you to use.


google analytics-login


Step 2: Once you are signed in with your Gmail account, you will be taken to the page shown below. This page is where you are going to signup for Google Analytics with the Gmail account you just created or currently have had.




Step 3: On the next page, you will have the choice choosing a website or mobile app. You are going to select the site. Next, you want to enter the account name. (This will be the Google Analytics profile name for your website). You also want to put in the website’s URL, industry category, and the correct time zone.




Once you have the above information entered you want to click on the Get Tracking ID button. The Google Analytics terms and service will now be shown. You must agree to these terms and service to have Google Analytics. Just click on the I agree button.

Step 4: You will now go to a page that has your Google Analytics tracking code. Just copy the tracking code because you are going to need to enter this code on your WordPress site.



Make sure you don’t leave the analytics browser tab as you might need to revisit it, once you have the tracking code successfully installed on your WordPress site.

Video Tutorial: How to Install Google Analytics in WordPress

How to Install Google Analytics in WordPress

There are a variety of ways you can easily set up Google Analytics in WordPress. We are going to go over three different ways to easily install Google Analytics in WordPress. The first method we go over is the easiest and the way that almost all beginners use. Use the method that is easiest for you.

1. Google Analytics for WordPress by MonsterInsights

If you search for Google Analytics plugins for WordPress, you will quickly realize that the plugin MonsterInsights is the most popular analytics plugin. The plugin has over 1 million downloads and is used by many Fortune 500 companies.

In our opinion, it’s one of the easiest ways to add Google Analytics to your WordPress site. MonsterInsights offers a free version and a Pro version. For most sites, the free version is more than enough. We will be using the free version for this tutorial.

You want to start off by installing and activating the MonsterInsights plugin. If you need some guidance, you can go to our post we did on how to install a WordPress plugin.

Once you install and activate the plugin, the MonsterInsights plugin will add a new menu item labeled ‘Insights’ to the WordPress admin menu. You want to go to visit Insights > Settings to configure the plugin settings.




On this page, you want to click on ‘Authenticate with your Google account’ button to connect Google Analytics to your WordPress site.




You will now see a popup where you are going to authenticate the plugin with your Google account you created or that you already had.




You now want to click on ‘Next’ to continue. You now want to click on the ‘Click to get Google code’ button.



You will now see a popup with a message saying, ‘MonsterInsights would like access to your Google Analytics data.’ You want to click on the ‘Allow’ button.




You will now see an authentication popup. It’s going to show you a line of code that you are going to copy.




Once you copy the line of code you want to exit out of the little window with the code and enter this code in the MonsterInsights popup and click on ‘Next.’




You are now at the last step. You want to select the profile you want to track. You will select your website and then click on the next button.




You have successfully installed and setup Google Analytics on your WordPress site. Something to keep in mind is it will take some time at first for Google Analytics to start showing your stats. So don’t be worried if you notice it isn’t showing it right from the start.

The MonsterInsights plugin has some excellent features. One of the best features is it allows you to view your Google Analytics report right inside your WordPress dashboard. To do this, you just go to Insights > Reports to see an overview of your analytics data.




Another great feature is if you go to Insights > Settings and click on the Tracking tab towards the top you can customize the tracking settings based on whatever your needs are.




2. Insert Headers and Footers Plugin

By using this method, you won’t be able to view the Google Analytics data right in your WordPress dashboard, and you won’t be able to take advantage of the advanced tracking configuration included in the MonsterInsights plugin.

For this method, you want to start off by installing and activating the Insert Headers and Footers plugin. If you need some help check out our post on how to install a WordPress plugin.

Once the plugin is installed and activated you want to go to Settings > Insert Headers and Footers page.




You want to now paste your Google Analytics code that you copied mentioned above in step 4 into the headers section. All you have to do now is hit the save changes button to save the settings.




3. Install Google Analytics in WordPress Theme

This method is a little bit more advanced, and we would recommend it if you have a good amount of WordPress knowledge and are familiar with code. We do want to point out that this method can be a little unreliable just because if you switch themes or update your theme the code will disappear and you will have to input it again. We don’t recommend using this method. If you have never added code to your WordPress files, I recommend you check out our post on how to copy paste code snippets in WordPress.

Add code in header.php file

To start off, you want to go to the Appearance in the WordPress dashboard menu and then select Editor.




You want to find the header.php file over on the right-hand side.




Once you find it click on it and then you are going to paste the Google Analytics tracking code mentioned above in step 4 right after the <body> tag. Now just click update file towards the bottom of the page to save your changes.

Add via Functions File

Another way you can add your Google Analytics tracking code to your site is to add the tracking code to the WordPress functions file. By doing this, it will automatically add the code to every page on your WordPress site. The code is going to be added to your theme’s functions.php file. To do this follow the tutorial below.

You want to start off by going to Appearance in the WordPress dashboard menu and then select Editor.




Now find the functions.php file over on the right-hand side.




At the top of the theme’s functions.php file you want to add the following code.


add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>
// Paste your Google Analytics code from Step 4 here
<?php } ?>


Once you add the code click update file to save your changes.

Viewing Reports on Google Analytics Website

Google Analytics will show you a ton of useful data that it collects from your stats. To view this data, you simply go to the Google Analytics dashboard and then click on the reporting tab over on the left-hand side. Each section that is labeled in the left column is divided into different tabs. By clicking on a tab in the left column, it will expand to show more options.

A helpful tab is the Audience tab. It shows reports that will help you understand your site’s users.

Acquisition reports show you where your site’s users came from.

Behavior reports show you what your site’s users do after they arrive on your site.

Conversion reports will show you how you are doing with your goals you set in Google Analytics.

Final Thoughts

We hope this article helped you and showed you how to install Google Analytics in WordPress.

Let us know in the comments below if this was helpful! We would love to hear from you.

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.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *