Beginner’s Guide to Installing Google Analytics in WordPress

Do you want to add Google Analytics to your WordPress site? It’s critical to understand how your visitors interact with your website if you want to be successful.

The best way to understand your audience is to look at your traffic statistics, which Google Analytics offers for free.

In this article, we’ll go over why Google Analytics is important and how to easily install it on your WordPress site (step by step).

We’ll start by explaining why Google Analytics is important and how it can assist you in growing your website.

After that, we’ll show you how to create a Google Analytics account and how to install it on your WordPress site using various methods.

Finally, we’ll show you how to use Google Analytics to view your traffic reports.

Here’s a quick rundown of everything you’ll learn in this article.

  • What is the significance of Google Analytics?
  • How to Create a Google Analytics Account
  • How to Use MonsterInsights to Install Google Analytics (Recommended)
  • How to Use the Insert Headers & Footers Plugin to Install Google Analytics
  • (Advanced) How to Install Google Analytics in a WordPress Theme
  • Viewing Google Analytics Reports
  • Using Google Analytics to Its Full Potential
    • Let’s get this party started.

      Video Instructions

      You can continue reading the text version below if you don’t want to watch the video tutorial:

      What are the Benefits of Google Analytics for Bloggers?

      As evidenced by the following: When you first start a blog, your primary goal is to increase traffic and subscriber numbers. By displaying the statistics that matter, Google Analytics assists you in making data-driven decisions.

      Who is it that comes to your website?

      This section of analytics tells you where your audience is from, which browser they used to visit your site, and other pertinent details like screen resolution, JavaScript support, Flash support, language, and more.

      You can use user data to ensure that your site is compatible with your target audience when getting a custom design. This information is extremely beneficial and can be used in a variety of ways.

      If the majority of your users don’t have Flash installed, you should avoid including it in your site. If the majority of your users are using screen resolutions of 1280 pixels or lower, make sure your design is compatible with that resolution or lower.

      When people visit your website, what do they do?

      You can track where users go on your website, how long they stay there, and what your bounce rate is (the percentage of users who leave after their first visit).

      You can lower your bounce rate and increase your pageviews by using this data.

      You can also see which articles are the most popular, which ones aren’t, and what kind of content your users are looking for.

      What are the most popular times for people to visit your website?

      You can choose the time to publish your post by looking at the busiest hours of the day for your site. If that time zone conflicts with yours, you can schedule your post to coincide with that hour.

      What is the best way for people to find your website?

      This section of the analytics shows you where the users came from (for example, search engines, direct links, and other sites’ referral links).

      Each of these categories is broken down by Google Analytics. If it’s the search engine category, it’ll show you which search engine, such as Google, Yahoo, or Bing, brought you the most traffic. It also tells you how much of your traffic came from each of these sources.

      If Facebook is your primary referral source, you’ll need exclusive Facebook content to make your Facebook audience feel special. The breakdown of referral sources reveals which sites you should focus on.

      If an external website is your top referral source, you should consider forming a partnership with it (via a guest post exchange or something else).

      What are people’s reactions to your content?

      It tells you how many people visited your site and what percentage of them clicked on which link, among other things. Google Analytics displays how visitors interact with the content on your website.

      To figure out what works best to meet your goals, you can run A/B split tests in Google Analytics by creating content experiments.

      You can work your content around your users by seeing how they interact with it. You can focus on the strategies that work for your site and avoid the ones that don’t by looking at the answers to the questions above.

      Simply put, get rid of the guesswork and concentrate on the numbers that matter so you can make data-driven decisions.

      How to Create a Google Analytics Account

      The sign up process is straightforward; simply follow the steps below to set up your Google Analytics account. Google Analytics is completely free, and all you need to sign up is a Google or Gmail account.

      Step 1: Go to Google Analytics and sign up for an account.

      You can sign in with your Google or Gmail account if you already have one. You’ll be prompted to sign in using your Google account. Otherwise, you can go ahead and create your own Google account.

      Step 2: After signing in with your Gmail account, you’ll see a screen similar to the one below. With your Gmail account, you’ll sign up for Google Analytics here.

      After that, you’ll be asked to choose a username for your account. This name will only be used internally, so it can be anything similar to your company name.

      Step 3: On the next screen, you’ll have the option of choosing between a web, apps, or both web and apps. Make sure that ‘Web’ is selected.

      Following that, you must enter the website name, URL, country, and time zone.

      Click the Next button once you’ve finished entering this information. You will be presented with Google Analytics terms and conditions, which you must accept by clicking the “I Agree” button.

      You can copy this tracking code because, depending on the method you use below, you’ll need to paste it into your WordPress site. Step 4: Your Google Analytics tracking code will now be displayed.

      You can also leave this browser tab open and return to it when you need to copy the code.

      Once you’ve installed the code on your WordPress site, we recommend leaving the analytics browser tab open in case you need to return to it.

      Let’s look at how to install Google Analytics in WordPress now that you’ve set up a Google Analytics account.

      Google Analytics in WordPress: How to Set It Up

      We’ll show you three methods, with the first being the simplest and the last being the most difficult. In WordPress, there are a few different ways to set up Google Analytics.

      You can select the one that best meets your requirements.

      Note: To avoid double tracking of page views in your Google Analytics account, you must only use one of these methods on your website.

      Method 1: MonsterInsights’ Google Analytics for WordPress

      Bloomberg, PlayStation, Zillow, WPBeginner, and others are among the 3 million websites that use it. The most popular Google Analytics plugin for WordPress is MonsterInsights.

      It is by far the simplest and best way to add Google Analytics to WordPress (for both beginners and experts).

      We’ll be using the MonsterInsights free version in this tutorial. Both a paid premium plugin and a free version of MonsterInsights are available.

      The procedure for putting them together is the same. If you want more advanced features like E-commerce tracking, Ads tracking, Author tracking, and so on, you can upgrade to the MonsterInsights Pro version.

      Let’s get this party started.

      See our step-by-step guide to installing a WordPress plugin for more information. Installing and activating the MonsterInsights plugin is the first step.

      When you activate the plugin, it will add a new menu item to your WordPress admin menu called ‘Insights’. The MonsterInsights setup wizard will open when you click on it.

      Select one, then click the ‘Save and Continue’ button to save and continue. You will first be asked to select a website category (business website, blog, or online store).

      Then, on the ‘Connect MonsterInsights’ button, click.

      This will open a popup that will ask you to sign in or select a Google account if you are already signed in.

      You’ll then be prompted to grant MonsterInsights access to your Google Analytics account.

      To proceed, click the ‘Allow’ button.

      The last step is to choose which profile you want to keep track of. To proceed, you must first select your website and then click the ‘Complete Connection’ button.

      After that, you’ll be asked to choose your website’s recommended settings. Google Analytics will now be installed on your website by MonsterInsights.

      You must add the path you use to cloak affiliate links if you use an affiliate link plugin. Most websites would be fine with the default settings. You’ll be able to track your affiliate links in Google Analytics as a result of this.

      To save your settings, click the Save and Continue button.

      To skip this step, simply click the ‘Save and Continue’ button. Then, if you upgrade to PRO, MonsterInsights will show you paid add-ons that you can use.

      Following that, you’ll be asked to install WPForms, the best WordPress contact form plugin. You can either install it or click ‘Skip this Step’ to skip it.

      Remember that Google Analytics will take some time to display your statistics. That’s it; your WordPress site has now been successfully installed and configured with Google Analytics.

      The best thing about MonsterInsights is that it allows you to view your Google Analytics reports right from your WordPress dashboard. To get a quick overview of your analytics data, go to the Insights » Reports page.

      It also includes a Popular Posts addon, which allows you to display your best-performing content to increase traffic and pageviews.

      It can be used to automatically add popular post links inline to increase engagement:

      If you have an online store, it can also automatically add your best-selling items at the end of each blog post to increase sales:

      MonsterInsights was previously known as Yoast’s Google Analytics for WordPress. It’s now part of our premium WordPress plugin family. Syed Balkhi, the founder of WPBeginner, bought the plugin in 2016 and renamed it MonsterInsights.

      Plugin for inserting headers and footers Method number two.

      Because you won’t be able to do advanced tracking configuration or view Google Analytics data in your WordPress dashboard, this method isn’t as good as MonsterInsights.

      To begin, copy your Google Analytics tracking code, which you copied in Step 4 when you signed up for a Google Analytics account.

      The Insert Headers and Footers plugin must then be installed and activated. See our step-by-step guide to installing a WordPress plugin for more information.

      You must go to the Settings » Insert Headers and Footers page after activation. In the ‘Scripts in headers’ section, paste the Google Analytics tracking code that you copied earlier.

      Don’t forget to save your changes by clicking the save changes button.

      That’s all there is to it; you’ve now successfully installed Google Analytics on your website.

      3. Make Google Analytics a part of your WordPress theme.

      This method should only be used by advanced users who are already familiar with the code. This is a method that we almost never recommend. It’s unreliable because your code will vanish if you change or update your theme.

      If this is your first time adding code to a WordPress file, see our tutorial on how to copy and paste code snippets in WordPress.

      To begin, copy your Google Analytics tracking code, which you copied in Step 4 when you signed up for a Google Analytics account.

      You may select one of them (but not both). There are two popular methods for including this code in your WordPress theme files.

      Include the code in the header.php file. 1st.

      Simply go to your WordPress theme’s header.php file and paste the Google Analytics tracking code you copied earlier after the <body> tag.

      Remember to save your changes before re-uploading the file to your server.

      Using the Functions File

      It will then add the tracking code to every page on your WordPress site automatically. The Google Analytics tracking code can also be added to the WordPress functions file.

      This code must be added to the functions.php file of your theme.

      Using the Google Analytics Website to View Reports

      Visit your Google Analytics dashboard to see this information. Google Analytics can show you a wealth of information gleaned from your statistics.

      Each section is divided into tabs, which can be expanded to reveal more options by clicking on them. In the left column, you’ll find the built-in Google Analytics reports.

      • Instantaneous This report will provide you with a real-time snapshot of your traffic.
      • The Audience tab will display reports that will assist you in better understanding your users.
      • The origins of your users are investigated in acquisition reports.
      • Your users’ actions after they arrive on your site are summarized in behavior reports.
      • Conversion reports show how well you’re meeting your objectives.

      Using Google Analytics to Its Full Potential

      Google Analytics is a fantastic tool with a ton of useful features. Some are self-explanatory and simple to use, while others require additional setup.

      Here are some tools to help you get the most out of your Google Analytics reports.

      • Google Analytics can be used to track user engagement in WordPress.
      • Google Analytics can be used to track WooCommerce customers.
      • In WordPress, you can keep track of outbound links.
      • Conversion Tracking in WordPress Made Easy – A Step-by-Step Guide

      It enables you to monitor the performance of your website in search results. Google Search Console (formerly Google Webmaster Tools) is the best way to use Google Analytics. Learn how to use Google Search Console to grow your website by reading our complete Google Search Console guide.

      We recommend using the AIOSEO plugin for WordPress, which is an all-in-one SEO toolkit, if you want to improve your website’s SEO rankings and get more traffic.

      You might also be interested in our comprehensive guide to increasing blog traffic and our comparison of the best email marketing services. We hope this tutorial on how to install Google Analytics in WordPress was helpful.

      You can also find us on social media sites such as Twitter and Facebook. Please subscribe to our YouTube Channel for WordPress video tutorials if you enjoyed this article.

    Step-by-Step Instructions for Starting Your Own Podcast

    15 Things You Must Do Before Changing WordPress Themes Checklist

    Why is it so important to build an email list today? (6 Reasons)

    How to Transfer Your Blog from to Correctly

    Editorial Staff Information

    Over 1.3 million readers around the world rely on it. WPBeginner’s Editorial Staff is a group of WordPress experts led by Syed Balkhi.

    Is this blog updated to reflect the latest Google Analytics changes? Do they have any effect on blogs? Thank you.

    If you’re referring to Google Analytics v4, this article hasn’t been updated yet, but we’ll do so as soon as the integration is ready.

    That’s what I was attempting to do when I encountered their error. I’m at a loss for what to do. Does anyone have any suggestions? I got so far following these instructions before getting an “Authentication Issue” message. It then directed me to this article, but it doesn’t tell me what to do if I get the message “Authentication Issue”. I need to make sure I have a Google Analytics account, it says. It informed me that I lacked a Google Analytics account and that I needed to create one.

    If you have, you should double-check that you are using the correct Google account when connecting Google Analytics to your website. You should double-check that you followed our instructions for visiting the Google Analytics website and creating an account.

    This was extremely helpful in setting up my Google Analytics account. I tried the first one and it was extremely simple.

    We’re glad our guide was useful.

    To install any plugins, you’ll need the Business version of WordPress. Does the third option you listed work with WordPress’s basic or standard versions?

    Our tutorials are for sites; for information on’s current restrictions, please contact them.

    Hello there!! ………&#82 I have a question: if you do this by editing the header.php file in the theme, won’t it be overwritten when the theme is updated?

    Unless you create a child theme, you are correct.

    Hey, thanks for the tutorial.

    However, since installing the monsterInsights plugin, my website has become noticeably slower to load.

    Is that typical? It says â€reduce render blocking†when I run the speed test.

    More than likely, the tool you’re using doesn’t like the Google Analytics tag where it is, and because Google requires the tag to be in the header, it can cause a site to slow slightly, but not enough to be noticeable.

    Thank you for providing clear, step-by-step instructions. I’m a complete non-techie who is just getting started with a blog. I’m so glad I came across you!

    Is there a way to undo what I’ve done and switch to the MonsterInsights plug-in after watching this tutorial? I like having it on my dashboard, and it appears to be easier to read (once I figure out what everything means). I installed a header/footer plug-in on my site based on someone’s recommendation before I found out about you.

    You would remove the code from the Insert Headers and Footers plugin, which would also remove the code from your site, and you would then be able to add using the plugin method.

    Google Analytics no longer resembles what you display. It has been altered.

    Thank you for letting us know about the change; we’ll try to update our article as soon as we can.


    You were a Godsend!!

    Thank you for your assistance.

    We’re glad our guide was of assistance.

    I’m not sure what I did wrong, but my setup is incomplete; it’s not linked to my gmail account, but only to my website?

    If you have multiple Gmail accounts, you might want to switch between them to see if you can set up analytics on one of them. If you’ve already created an account, you should be able to log in using the Google account you used to sign up.

    I attempted to install Google Analytic functions.php in WordPress several times.

    Errors are displayed.

    Due to an error on line 67 of file wp-content/themes/Extra/functions.php, your PHP code changes were rolled back. .. Please correct the problem and try saving again.

    Expecting end of file, syntax error, unexpected ‘<'

    What are the solutions? Please advise me on what I should do next.

    For that specific error, you should try removing line 1 from the code in our guide.

    Thank you so much for sharing how to set up Google Analytics.

    We’re glad our guide was useful.

    I used Monster Insights to install Google Analytics on my blog, but I can only see analytics using the Monster Insights dashboard on WP; the analytics are not visible on the Google Analytics website.

    If you have multiple properties, double-check that you’re checking the correct one and that you’ve given Google Analytics 48 hours to populate the data.

    “The selected account does not have any Google Analytics Web properties,” I keep getting this message. Please use a different Google Account and ensure that your Google Analytics property is set to “Web” rather than “Apps and web” or “Apps”.

    This article has more information on how to set up your Google Analytics property.

    Choose a different app/profile to authenticate into”

    Thank you very much! Please assist! I’ve set my account to Web only, but I’m not sure if it’s a problem with the way I phrased the property?

    If you have multiple properties, make sure you’re connecting to the right one. If everything is set correctly, you can also contact MonsterInsight’s support for help with that error.

    Thank you!! Exceptionally beneficial!!!!

    You are most welcome.

    Is it possible to use the same Google account to set up Google Analytics for multiple websites? And how do you do it?

    There is an option in your Google Analytics Admin section to create a new account for your new site.

    the â Thank you very much! That’s exactly what I was looking for.

    Thank you for taking the time to read our guide; we hope it was useful.

    Thank you for your contribution! Your information is extremely useful in helping me set up Google Analytics!

    Thank you for taking the time to read our guide; we hope it was useful.

    unexpected ‘<', expecting end of file syntax error Following the instructions, I received the following error:

    It would depend on how you are attempting to add the code; for the time being, you might want to try some of the other suggested methods in the article.

    For the beginner, this is extremely beneficial.

    We’re glad you found our information useful.

    Excellent data. Thank you.

    Thank you for taking the time to read our guide; we hope it was useful.

    Totally free! Thank you for creating such well-considered content.

    You’re welcome, and we’re glad you found our information useful.

    Dear Colleagues, Please assist me in resolving this issue. But when I tried to verify it, it said “verification failed”. Using the insert Header and Footer plugin, I attempted to connect Google Analytics code to WordPress.

    For the most common solution to this problem, you should start by clearing your site’s cache.

    Thank you so much! Instructions are excellent.

    Thank you for taking the time to read our guide; we hope it was useful.

    It’s incredible! I really like how you walked through each step; it made everything so much clearer. I tried all three methods after watching you calmly and in real time go through it as a newbie.

    Subscribing and bookmarking

    We’re glad our guide was useful.

    Is there an article on how to add adsense to my website after that? Thank you so much, this was extremely helpful, and I was able to resolve the issue in a matter of minutes.

    For more information on how to add Google Adsense to your WordPress site, see

    Will the analytics be automatically added to a new page if I use the Monster insight or the “Insert header and footer plugin”, or will I have to set it up again if I create a new page after setting up the analytics? Hello, Thank you for this informative article; however, I have a question.

    Using either of those methods would add the code to your new posts and pages automatically.

    I’d like to set up Google Analytics without the use of Google Tag Manager. Thank you for providing this useful information. Please tell me where I can get the code for this.

    If you do not intend to use Google Tag Manager on your site, you should not add it.

    Thank you for the thorough explanation. Very beneficial

    You are most welcome.

    Now that you’ve completed all of the steps, I’m ready to go! Thank you very much. OMG, it’s so simple and helpful!

    You are most welcome.

    It was extremely beneficial. The steps to take were easy to follow and comprehend.

    We’re glad you found our article to be useful.

    Thanks, I’m not very knowledgeable about any of this, but I was able to install Google Analytics without difficulty by following your instructions.

    Now let’s move on to something else!

    We’re glad our guide was able to assist you.

    Thank you for being so helpful, brother.

    You are most welcome.

    Because I prefer to have the Google Analytics app on my phone where I can view all websites, I used the Headers and Footers Plugin. Thank you very much! This video is extremely helpful.

    This article was extremely useful and contained all of the information I needed. Thank you very much.

    You are most welcome.

    I can’t wait to find out more.

    We hope that our resources will be of assistance.

    Thank you very much! This was extremely simple to follow, and I was able to set up Google Analytics with Monster Insights in no time.

    We’re glad we could assist in making the process easier for you.

    It’s very good and practical.

    Thank you for taking the time to read our guide; we hope you found it useful.

    Hello there! This is an incredible tutorial.

    However, when I tried the third method, I received the following message: Your PHP code changes were rolled back due to an error on line 1006 of file wp-content/themes/oceanwp/functions.php. Please correct the problem and try saving again.

    unexpected syntax error ‘<', anticipating the file’s end

    Please assist.

    You should be able to add the code without the first line if your functions.php did not close its PHP.

    That worked for me – I just removed the ‘<?php' and the error went away.

    Thank you.

    It does not support the installation of plugins. Hello there. My plan is completely free. What can I do in that case to make use of Google Analytics?

    For sites, you’ll need to consult the support documentation to see what they currently allow.

    Hello there,

    I correctly installed Google Analytics, and it works perfectly!

    However, it is also tracking my IP address.

    I couldn’t locate it anywhere. Is there a way to solve this issue?

    One of the reasons we recommend MonsterInsights is that it can filter out your own visits without the need for a Google Analytics filter.

    I follow the steps in the video tutorial exactly, but I can’t update my theme editor file, which says:

    Due to an error on line 83 of file wp-content/themes/neve/functions.php, your PHP code changes were rolled back. Please correct the problem and try saving again.

    ‘<', anticipating the file’s end unexpected syntax error

    beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/ For the most common reasons for such an issue, we recommend reading our guide on copying snippets from the web below:

    Thank you for all of this; G Analytics is something I’ve been putting off implementing because my brain shuts down at the thought, but you’ve clarified things for me!

    I’m pasting the code using Insert Headers and Footers, but I already have code on there for other things – can I paste code directly below?

    Yes, you would place the new code beneath the existing code.

    This clearly explained how to set up Google Analytics on my website, and I appreciate that I don’t have to put code on each page, as I was perplexed on the Google Analytics page. I’m just getting started with my website, and you’ve been a huge help. Thank you very much.

    We’re glad our guide was able to make the process easier for you.

    Thank you so much, man…you’ve been extremely helpful.

    We hope you found our article useful.

    They make it so difficult. Is there another website besides wordpress where I can add the hmtl code I want without having to buy anything, install a plugin, or update my account? I can’t seem to find a good site that explains how to add Google tracking code to a WordPress site without using a plugin. What is the point of a plugin in the first place?

    To connect Google Analytics, currently requires one of their paid plans. It appears that you are using, which would be the primary cause of that problem; you might want to check out our comparison here:

    simply to express my gratitude

    Thank you for taking the time to read our guide; we hope you enjoyed it.

    Hello there,

    I just wanted to know if I put code in the header.php file, do I have to put it in functions.php as well? Will just updating header.php suffice? I’m using #3 to integrate GA into my WordPress theme.

    You would use one of the methods; you would not want to use both, and which method you use is a matter of personal preference.

    Thank you so much for sharing your knowledge!

    You are most welcome.

    You mention that Google Analytics takes some time to connect to the website. My Siteground dashboard displays sessions and pageviews, but GA continues to show zero. Thank you so much for sharing your knowledge! In general, how long does that procedure take?

    Thank you for your assistance!

    Normally, it takes between 24 and 48 hours, but this can vary.

    Thank you for your time and consideration. I can’t paste the analytics code on my web pages because I can’t paste it. Will this plugin send the hits to my main analytics account (web)?

    It will send the data back to your Google Analytics account as long as it is connected.

Enable registration in settings - general