WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
  • Deals
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Beginners Guide» How to Install Google Analytics in WordPress for Beginners

How to Install Google Analytics in WordPress for Beginners

Last updated on February 14th, 2019 by Editorial Staff
1.9k Shares
Share
Tweet
Share
Pin
Special WordPress Hosting offer for WPBeginner Readers
How to Install Google Analytics in WordPress for Beginners

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).

How to Install Google Analytics in WordPress

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

Subscribe to WPBeginner

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.

Google Analytics login

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.

Google Analytics signup

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.

Set up your Google Analytics account

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.

Google Analytics tracking code

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.

Authenticate with your Google account

This will redirect you to Google accounts where you will be asked to sign in or select a Google account if you are already signed in.

Sign in or select your Google account to continue

Click on ‘Next’ to continue.

Now you will be asked to allow MonsterInsights to access your Google Analytics account.

Allow MonsterInsights to access your Google Analytics account

Click on the ‘Allow’ button 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 ‘Complete authentication’ button to continue.

Select your website profile

You will be now redirected back to your WordPress site.

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.

MonsterInsights reports

You can go also go in the Tracking tab to customize the tracking settings based on your needs:

MonsterInsights tracking

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.

Adding Google Analytics tracking code using Insert Headers and Footers plugin
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.

Google Analytics reports

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.

1.9k Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

629 Comments

Leave a Reply
  1. Faizan Zafar says:
    Feb 2, 2019 at 2:34 pm

    I am very much confused how to add google analytics to my site. If i donot want to use the pluggin which steps I should take?

    Reply
    • WPBeginner Support says:
      Feb 4, 2019 at 2:39 pm

      If you do not want to use a plugin then you would want to create a child theme and use the third method in the article to add the code. For how to create a child theme you can take a look at: https://www.wpbeginner.com/glossary/child-theme/

      Reply
  2. Eric says:
    Jan 7, 2019 at 4:14 pm

    Very good post. As a newbee in this field, I was able to install the Insert Headers and Footers Plugin and connect with Google Analytics. This was for my Photography website.
    Besides this, I also have a business website where I want to install this plugin and have Google Analytics. How can I do this? When I signin with Google, I am always redirect to Google Analytics of my Photography website?
    How can I have a new script for my business website?
    I hope to get a clear answer as I’m a newbee :-)

    Reply
    • WPBeginner Support says:
      Jan 7, 2019 at 11:51 pm

      Hi Eric,

      Google Analytics allows you to add multiple websites. It calls them properties. Under your Google Analytics account click on the “Admin” menu at the bottom left corner of the screen. After that you will see an option to Add Property.

      Reply
  3. Michelle says:
    Jan 4, 2019 at 7:42 pm

    I’m so grateful for this article! I have been banging my head trying to figure this out on my own. Thank you!

    Reply
    • WPBeginner Support says:
      Jan 8, 2019 at 10:04 am

      Glad our guide could help you :)

      Reply
  4. Daniel Ajumobi says:
    Dec 18, 2018 at 10:29 pm

    Thanks so so much.
    Quite helpful and relieving.

    Reply
    • WPBeginner Support says:
      Dec 19, 2018 at 10:53 am

      Glad our article could be helpful :)

      Reply
  5. Tiago says:
    Nov 10, 2018 at 5:56 pm

    Hi, I already had the Headers and footers plugin, since I have installed Monstterinsights, can I now uninstall Headers and Footers? Thanks.

    Reply
    • WPBeginner Support says:
      Nov 12, 2018 at 3:57 am

      Hi Tiago,

      If you were using Insert Headers and Footers plugin just for Google Analytics code, then you can uninstall it after setting up MonsterInsights.

      Reply
  6. Melanie says:
    Oct 25, 2018 at 12:36 pm

    Being a newbie at blogging, I see now that when I first set up my blog I used the Insert Headers and Footers for my Analytics code. A year later (not knowing what I was doing) managed to set up MonsterInsights with a new Google Analytics account. I have now realized that I have two Google Analytics accounts tracking the same blog- one through Insert Headers and Footers and the other through MonsterInsights. Interesting to note, Insert headers and footers shows more visitors a month (almost 5,000 more). Which one do you think is more accurate? Which one do you think I should keep? Are there any negatives if I stop using one of them? Thanks so much for this video and advice!

    Reply
  7. Tyler says:
    Oct 13, 2018 at 9:38 am

    I can NOT seem to access the functions.php folder ANYWHERE!!! :( For whatever reason when I click on “Appearance” in the sidebar all I see is “Themes, customize, widgets, menus, header, background, theme options, amp, and Mobile” Where is Editor?? What is going on??

    Reply
    • WPBeginner Support says:
      Oct 14, 2018 at 2:51 pm

      Hi Tyler,

      functions.php is a file not a folder. You can also access it using FTP, simply connect to your website and go to wp-content/themes/your-theme-folder/ inside you will see your theme’s functions.php file which you can then edit using a plain text editor like notepad.

      Reply
  8. zoziano says:
    Sep 22, 2018 at 1:49 pm

    Well, i thought you were kidding. Many Tutorials make it so complicated and you got it done in 3 minutes!
    Thank you so much for that!

    Reply
  9. krider says:
    Sep 20, 2018 at 3:53 pm

    which one is best plugin one or directly adding code to header…which one make page slow or website slow as compare to other

    Reply
  10. Daniel says:
    Aug 13, 2018 at 11:17 am

    It is awesome thanks for the guidance!!!!!!!!

    Reply
  11. Sagar Mandan says:
    Aug 12, 2018 at 12:29 am

    Hi,

    I was using last method previously. I recently upadated theme. I was adding code in header.php and was adding code below tag. Because now I am unable to track and also unable to see code in view source Does mosterinsights show on analytics.google.com.

    Am I correct.

    Reply
  12. Helena says:
    Aug 11, 2018 at 3:07 pm

    I don’t know what’s wrong but my Analytics only detects AMP view so I tried to add new GA account and followed all these steps. Hope my stats back to normal. Thank you.

    Reply
  13. Gabriel says:
    Aug 1, 2018 at 11:26 am

    Hi…
    Is it posaible to add two websites to a single google analytic account?
    If yes, how can I do that?

    Reply
    • WPBeginner Support says:
      Aug 2, 2018 at 7:30 pm

      Hi Gabriel,

      Yes, you can add multiple websites to Google Analytics using the same Google account. Simply go to Google Analytics dashboard and click on the ‘Admin’ button. On the next screen, you can click on ‘Create New Account’ button and add another website.

      Reply
  14. Speaker Tim White says:
    Jul 13, 2018 at 1:57 am

    Hi guys!

    Long time fan and customer (Love my WPForms!).

    Question regarding this great post:

    Are there any negative effects if I add BOTH plugins?

    Thanks for your great work,

    Speaker Tim White

    Reply
    • WPBeginner Support says:
      Jul 13, 2018 at 3:21 pm

      Hello Tim,

      Yes, there are negative effects if you used both plugins. They will both be loading Google Analytics which would affect reporting. We recommend using MonsterInsights, because it will give you access to beautiful reports and advanced features.

      Reply
  15. Timo says:
    Jul 1, 2018 at 4:03 am

    Great description! I’m a WordPress-beginner and found it incredibly useful. I set it up in just a few minutes thanks to your detailed step-by-step-instructions! :)

    Reply
  16. Cory says:
    Jun 12, 2018 at 6:08 pm

    Thank you so much! This was incredibly helpful! The video made it so easy.

    Thank you guys :)

    Reply
  17. Le Huu Tai says:
    Jun 10, 2018 at 4:32 am

    Hey dude,

    This is really complete. However, I rather to know that is it better to install GA later when a new site reaches a certain decent traffic

    thank you

    Reply
    • Joey S says:
      Jun 13, 2018 at 1:24 am

      I’m not sure I agree with this. I don’t think it’s ever too early to setup GA. in fact it’s one of the first things I setup. Almost no fun if you can’t see what kind of traction your blog is getting.

      Reply
  18. majju says:
    Jun 6, 2018 at 6:57 am

    when i’m clicking on monsterinsight install. nthng is happening and install button is not accessible to me.

    Reply
  19. Rohit jaiswal says:
    Apr 30, 2018 at 4:14 am

    Simply edit the header.php file in your WordPress theme and paste the code you copied in step 4 right after the tag.

    Is it really true ” right after the tag.” ?

    Reply
« 1 … 7 8 9

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
MonsterInsights
MonsterInsights
Google Analytics made easy for WordPress. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 25 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2019 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2019)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2019)
    • SiteGround Reviews from 1032 Users & Our Experts (2019)
    • Bluehost Review from Real Users + Performance Stats (2019)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Start a Podcast with WordPress (Step by Step)
    • How to Choose the Best Domain Name (8 Tips and Tools)
    • How to Setup a Professional Email Address with Google Apps and Gmail
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2019 – Step by Step Guide
Deals & Coupons (view all)
Dreamhost
DreamHost Coupon
Get 40% OFF on DreamHost and get a Free Domain.
Elegant Themes
Elegant Themes Deal
Get all 87 amazingly beautiful WordPress themes by Elegant Themes for only $69. That is like $0.79 per theme!
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • Awesome Motive

Copyright © 2009 - 2019 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

WordPress hosting by HostGator | WordPress CDN by MaxCDN | WordPress Security by Sucuri.