Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

How to Install Google Analytics in WordPress for Beginners

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

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 provides for FREE.

In this article, we will share why Google Analytics is important and how you can easily install Google Analytics in WordPress (step by step).

How to Install Google Analytics in WordPress

First, we will 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 methods to install it on your WordPress site.

Finally, we will explain how to view your traffic reports in Google Analytics.

Here is a quick overview of what you’ll learn in this article:

Ready? Let’s get started!

Why Is Google Analytics Important for Bloggers?

Once you start a blog, your #1 goal is to get more traffic and subscribers. Google Analytics helps you make data-driven decisions by showing you the stats that matter. You can see:

Who visits your website?

This part of analytics shows the geographical location of your audience, which browser the user used to visit your site, and 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 creating a custom website 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 the Flash element to 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 users are going on your website, how long they stay on your website, and the bounce rate (the percentage of users who exit your site on the first visit).

Using this information can decrease the bounce rate and increase your pageviews.

You can also find your most popular articles, articles that are not doing so well, and the kind of content your users are looking for.

When do people visit your website?

By looking at the hottest hours in the day for your site, you can pick the best time to publish your post. If that time zone is not compatible with yours, then you can schedule your post for that hour.

How do people find your website?

This section of the analytics shows you where the users come from. For example, do they use search engines, enter direct links, or click on referral links from another site?

It also shows you what percentage of your visitors came from each of these sources. Google Analytics gives you a 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, like Google, Yahoo, Bing, and so on.

The breakdown of referral sources shows you which sites you need to work with the most. If your top referral source is Facebook, you need exclusive Facebook content to make your 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 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 avoid methods that don’t work.

Simply put, eliminate the guesswork and focus on stats that matter, so you can make data-driven decisions.

Video Tutorial

Subscribe to WPBeginner

If you’d prefer written instructions, keep reading.

How to Sign Up With Google Analytics

Google Analytics is available for free, and all you need is a Google or Gmail account to sign up. The signup process is quite simple. Just 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. When you are on the website, simply click the ‘Get started today’ button.

Click get started today

Next, you will be asked to log in with your Google account.

If you already have a Google or Gmail account, then you can use that to sign in. Otherwise, you can go ahead and create a Google account for yourself.

Sign in using your Google account

Step 2: Once you have signed in with your Gmail account, you will see a welcome screen like the one below.

This is where you will sign up for Google Analytics with your Gmail account. Go ahead and click the ‘Start measuring’ button.

Click start measuring button

After that, you will be asked to provide an account name.

This name will be used internally, so you can use anything, like your business name.

Enter your Google account name

Google Analytics will also show multiple account data-sharing settings.

These settings give you control over sharing your Google Analytics data. You can keep the default settings and move on to the next step.

Account data sharing settings

Step 3: On the next screen, you will need to create a Google Analytics property.

Google introduced 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. Plus, you get new features, metrics, and a different interface for your reports.

Go ahead and enter a property name, and select your reporting time zone and currency. Then click the ‘Next’ button.

Enter property name

On the next screen, you’ll need to select an ‘Industry category’ from the dropdown menu for your website and choose a ‘Business size’ from the given options.

When you are done, just click the ‘Next’ button.

Enter business details

Next, you’ll need to choose business objectives and select how you intend to use Google Analytics with your business. This will help get personalized reports for your business.

For instance, there are options like generating leads, driving online sales, raising brand awareness, examining user behavior, and more.

You can choose multiple options or all of the given options that meet your needs. We recommend selecting the ‘Get baseline reports’ option so that you get all the Google Analytics reports populated in your account.

Choose your business objectives

When you are done, simply click the ‘Create’ button.

Step 4: Now you will be presented with your Google Analytics Webs stream options.

Since we are setting up Google Analytics for a WordPress site, go ahead and select the ‘Web’ as the platform.

Select data collection option

After that, you’ll need to enter your website URL and Stream name.

By default, Google Analytics will have an ‘Enhanced measurement’ option enabled. This allows you to track pageviews, scrolls, outbound clicks, file downloads, and more in Google Analytics.

Note: If you plan to use the MonsterInsights plugin, then you should turn off the ‘Enhanced measurement’ option. Otherwise, the plugin will collect and display double the amount of data.

Next, you can click the ‘Create stream’ button.

Enter website URL and stream name

You can now see your Stream name, URL, ID, and Measurement ID.

It will also show different enhanced measurements that it will record.

View stream ID and measurement ID

At the top, you will also see an alert bar that will show you how to add Google Analytics to your WordPress site.

Go ahead and click the ‘View tag instructions’ button. You should now see different ways to add the Google Analytics tracking code to your WordPress website.

View Analytics installation instructions

Next, you can switch to the ‘Install manually’ tab.

You’ll then see the Google Analytics tracking code.

Install GA code manually

Go ahead and copy this tracking code because you will need to enter it in your WordPress site depending on the method you use below. You can also simply leave this browser tab open and switch back to copy the code when needed.

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 set up a Google Analytics account, 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 will show you three methods where the first option is the easiest and the last is the hardest.

You can choose the one that best suits your needs.

Note: You need to use only one of these methods on your website to avoid double tracking of pageviews in your Google Analytics account.

Method 1: Google Analytics for WordPress by MonsterInsights

MonsterInsights is the most popular Google Analytics plugin for WordPress. Over 3 million websites use it, including the likes of Bloomberg, PlayStation, Zillow, WPBeginner, and more.

It is the easiest and by far the best way to add Google Analytics to WordPress (for all users, beginners, and experts alike). MonsterInsights is available as both a paid premium plugin and a free 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, and so on. The process of setting them up is the same.

For more information, you can see our complete MonsterInsights review.

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, and you’ll see a welcome screen. Go ahead and click the ‘Launch the Wizard’ button.

Launch setup wizard

Clicking on it will open the MonsterInsights setup wizard.

First, you will be asked to choose a category for your website (a business website, blog, or online store). Select one and then click on the ‘Save and Continue’ button.

Choose what describe your website

Next, you need to connect MonsterInsights with your WordPress website.

Simply click on the ‘Connect MonsterInsights’ button.

Connect MonsterInsights with your site

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

Go ahead and choose your Google account or enter your email to sign in.

Choose Google account to sign in

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

Click on the ‘Allow’ button to continue.

Allow access to your Google account

The next step to completing the connection is to select the profile you want to track.

You need to select your website here and then click on the ‘Complete Connection’ button to continue.

Connect analytics with your site

After that, simply click on the ‘Complete Connection’ button to continue. MonsterInsights will now install Google Analytics on your website.

Next, you will be asked to select the recommended settings for your website.

Recommended settings

The default settings will work for most websites. If you use an affiliate link plugin, then you need to add the path you use to cloak affiliate links. This will allow you to track your affiliate links in Google Analytics.

MonsterInsights will also ask who can see the reports. You can choose different WordPress user roles.

Once you are done, just click on the ‘Save and Continue’ button to save your settings.

Who can see the reports

Next, MonsterInsights will show you a list of website tracking features you would like to enable.

You can scroll down and click on the ‘Continue’ button or the ‘Skip for Now’ option.

Choose which tracking features to enable

On the next screen, MonsterInsights will show that you’ve successfully set up Google Analytics tracking.

You can see that Google Analytics is connected, the tracking code is installed, and data is now being collected.

Tracking should be all setup

Next, you can scroll down and see a field to enter your license key.

Go ahead and click the ‘Complete Setup without Upgrading’ option for now.

Continue setup without upgrading

You’ve successfully added Google Analytics to your WordPress website.

Disable Enhanced Measurement in Google Analytics

Now, if you created a Data Stream in GA4 on your own instead of letting MonsterInsights create one, then you’ll need to switch off Enhanced Measurement.

That’s because MonsterInsights adds multiple custom-enhanced tracking features. Leaving the Enhanced Measurement option enabled will skew your data and show incorrect results.

First, you can head to the Google Analytics tab or window in your browser. From here, click on the ‘Admin’ settings option in the bottom left corner.

Switch to admin view in Google Analytics

Once you are on the ‘Admin’ page, you’ll see different settings.

Simply click on the ‘Data Streams’ option.

Go to admin and data stream settings

Next, you’ll see your Data Streams.

Simply select the data stream you connected with MonsterInsights.

Select your data stream

On the next screen, you will need to disable the ‘Enhanced measurement’ option.

To do that, simply click the toggle.

Disable enhanced measurement

Next, a popup window will open, confirming that you’d like to turn off the enhanced measurement.

Go ahead and click the ‘Turn off’ button.

Click turn off button for enhanced measurement

Change Data Retention Settings in Google Analytics

By default, Google Analytics will set the data retention setting to 2 months. However, you can change this so that you can use your data in custom reports beyond 2 months.

First, you need to head to Admin » Data Settings » Data Retention in Google Analytics.

Open data retention settings

Next, you can click the ‘Event data retention’ dropdown menu.

From here, simply select the ’14 months’ option and click the ‘Save’ button.

Change data retention settings

Remember, it will take Google Analytics some time before showing your stats.

View Google Analytics Reports Inside WordPress Dashboard

The best thing about MonsterInsights is that you can view your Google Analytics reports inside your WordPress dashboard.

Simply visit the Insights » Reports page to check out a quick overview of your analytics data.

Dashboard reports

You can also add annotations directly to your 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, and so on. This makes it easy to track how these events impact your traffic.

View your site notes under the report

For more details, see this guide on how to get GA4 site annotations in WordPress.

In addition, it comes with a Popular Posts addon that allows you to show your top-performing content to boost your traffic and pageviews.

MonsterInsights Popular Posts Widget

You can use it to automatically add inline popular posts links to boost engagement.

If you are running an online store, then it can also automatically add your top-performing products at the end of each blog post to boost sales:

MonsterInsights popular products

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.

Method 2: Install Google Analytics in WordPress With WPCode

This method is 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 will need to copy your Google Analytics tracking code (Global site tag) that you copied in Step 4 earlier when creating a Google Analytics account.

Install GA code manually

Next, you need to install and activate the WPCode plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Code Snippets » Header & Footer page. Here you must paste the Google Analytics tracking code that you copied earlier into the ‘Header’ section.

Enter tracking code in header using WPCode

Don’t forget to click the ‘Save Changes’ button to store your settings.

That’s all, you have successfully installed Google Analytics on your site.

Method 3: Install Google Analytics in WordPress Theme

This method is for advanced users who are familiar with the 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 and paste code snippets in WordPress.

First, you will need to copy the Google Analytics tracking code that you copied in Step 4 earlier. You can view it in the Web Stream Installation section under the ‘Install manually’ tab.

Install GA code manually

Now there are two common ways to add this code to your WordPress theme files. You can choose either one of them (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 that you copied earlier right after the <body> tag.

Don’t forget to save your changes and upload the file back to your server.

2. Add via Functions File

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

You will need to add this code to your theme’s functions.php file.

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 your Google Analytics tracking code from Step 4 here’ section in the above snippet with your Google Analytics code.

Viewing Reports in Google Analytics

Google Analytics is capable of showing you a treasure trove of data collected from your stats. You can view this data by visiting your Google Analytics dashboard.

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.

GA4 reports

Google Analytics 4 reports are a bit different from previous Universal Analytics reports. In the left column, you’ll see a dedicated Reports option. The reports are grouped together under 2 broad categories, including Life Cycle and User.

One of the most noticeable differences you’ll find in GA4 reports is that there’s no bounce rate metric. Other than that, you’ll find a new reporting interface, new metrics like engagement time, no goals in GA4, and more.

Here’s a breakdown of different reports in Google Analytics 4:

  • Realtime report is similar to Universal Analytics and shows active users on your site in real time.
  • Acquisition report shows which medium users use to find your websites, like organic, referral, email, and affiliate.
  • Engagement report shows conversions and events that take place on your site.
  • Monetization report shows all your eCommerce data in one place, along with new reports like in-app purchases and publisher ads.
  • Retention report basically shows new vs. returning visitors and helps you get insights about user retention.
  • Demographics report helps you see website traffic from top countries, cities, and more. It also shows gender breakdown and interest reports.
  • Tech report shows which device, browser, operating system, app version, and screen size people use the most to view your website.

Making the Most Out Of Google Analytics

Google Analytics is an incredibly powerful tool with tons of awesome features. Some of them are quite obvious and easy to use, while others require some additional setup.

Here are some of the resources that will help you make the most out of Google Analytics reports.

Google Analytics works best with Google Search Console (formerly Google Webmaster Tools). It allows you to see how your website is doing in search results. See our complete Google Search Console guide to learn how to use it to grow your website.

If you want to improve your WordPress SEO rankings and get more traffic, then we recommend using the AIOSEO plugin for WordPress, which is an all-in-one SEO toolkit.

There’s also a free version of AIOSEO that you can use too.

This plugin will help you fully optimize your WordPress site with proper schema markup, sitemaps, and everything you need to improve your SEO rankings.

We hope this article helped you learn how to install Google Analytics in WordPress. You may also want to see our ultimate guide to increasing your blog traffic and our comparison of the best email marketing services.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

846 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Toby says

    Please I am having issues registering my blog to the google analytics. I keep being told that my blog URL is not allowed.

  3. Manzoor says

    Hey, i have installed monster insights. When i open it shows “You appear to be offline” I can’t see any stats or other things. Why? I can see stats by going to Google analytics website.

    • WPBeginner Support says

      It sounds like when you opened the page with MonsterInsights you had an internet issue. You would want to clear your cache and that should resolve the issue.


  4. Jaliah Nabbowa says

    Hi, I am using a personal plan so I can’t install any plugins.

    I have gone to my dashboard to try and install the code manually, so I scrolled to appearance but I don’t have an editor option.

    Does this mean I have to upgrade to business plan? Because that would be too costly for me.

  5. reena says

    i have added my google analytic code wordpress site ,so then also i am not getting traffic to my website,what will be the readon for the same

  6. Mina says

    Thank you for the information. I am currently using the first option but I recently got a message that says: No Hits

    Property is not receiving hits.

    I am no longer getting a page view analysis or any info.
    What can I do to resolve it?

    • WPBeginner Support says

      Have you tested with an incognito browser to see if it counts a hit? The MonsterInsights plugin would normally filter out admin activity


  7. Amer says

    I have blog on with premium (8 dollars a month) subscription and I can’t implement code from Google Analitycs. Is there any script for that or I must upgrade for bussienes plan or maybe migrate on

  8. Maria says

    Hi there! Thank you for yet another amazing article. So I had installed GA via Monster Insights a couple of years ago but I also have the Headers & Footers plugin for other uses anyway. I am currently looking into getting rid of some plugins so I want to ditch the Monster Insights one as I never look at the metrics from WP anyway. What should I do? Add the GA tracking code to header first and then delete Monster Insights plugin or vice versa? Will this change affect my stats somehow? Will I lose any stats in the process? Thank you so much in advance.

    • WPBeginner Support says

      You would want to add your code after removing MonsterInsights, you shouldn’t lose any data you would only lose any specific setup that you had in MonsterInsights such as filtering out your visits.


  9. CocktailTravellers says

    Amazing tutorial, thank you for taking the time to record and show all 3 methods. I have watched so many video’s that simply say, now add the code to your website, and then move on to the next topic. Have been looking for ages to find a video that shows you how to add the code.
    Thanks to Jaison from bluehost help for connecting me with this video!

    • WPBeginner Support says

      It would depend on the issue you’re running into, if there is an error, reach out to MonsterInsight’s support and they will be able to assist


  10. Paige says

    Well, unfortunately this plugin crashed my website and WP is asking for $185 to fix it. I cannot access my website to uninstall Google Analytics. Any suggestions? I am a true Beginner to all of this.

  11. Chris says

    Hi. In section 3 where you say to add the code immediately after the tag, shouldn’t that be immediately after the opening tag?

    • WPBeginner Support says

      We recommend the location we do in the article as your site would load the scripts above it first to start displaying your site before loading Google Analytics rather than first waiting for Google Analytics tracking then displaying your content.


  12. Becky Antkowiak says

    Hi, yesterday I installed using Monster Insights and kept scrolling to read, then closed down for the evening. Today, I opened it back up, forgot that I’d already installed MI and used the header/footer method. Will they cancel each other out, or is it okay to leave it?


    • WPBeginner Support says

      You would want to remove the header method and keep the MonsterInsights method if you want to keep using MonsterInsights. If you don’t remove the extra method then it would show incorrect information.


  13. Roma says

    Thanks so helpful, and so easy to follow. I stuck with your header and footer plugin as analytics stop communicating with another plugin that I was using.

  14. Patrick Schmitt says

    The insert header and footer plugin helped me a lot. I use Flatsome child plugin and dont know how it works with that system…

    with the plugin it was easy going :)

    Thanks a lot!

  15. San says

    Thanks for this article, it’s very clear and easy to follow. I have successfully installed monsterInsights and have been tracking for a few days now.

    However Analytics seems to track only normal pages and not post-type pages (posts, news, etc.) on my site. Any ideas how to fix this? Thanks!

    • WPBeginner Support says

      If it’s not tracking your analytics correctly for your posts, if you reach out to MonsterInsights’ support they should be able to help you check for any errors with the plugin.


  16. Shireen says

    Your PHP code changes were rolled back due to an error on line 534 of file wp-content/themes/infinite/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘<'

    That's the message I get :-/

    • WPBeginner Support says

      It would depend on the method you were using to place the code for why that error is popping up. If you’re using the manual method you may want to try adding to your functions.php


  17. Alessio says

    Can I use Google Analytics with a Premium subscription in WP?
    I’ve this doubt ’cause on the official subscription page they say that the Premium account doesn’t support Google Analytics.

    • WPBeginner Support says

      If you’re on then they normally require the business plan, our tutorials are for sites :)


    • WPBeginner Support says

      You would either use inspect element to see if your code was added to your site or you could wait the 14-48 hours to see if it starts collecting your site information.


  18. Melissa says

    When I try to set up google analytics it says my URL is invalid. I have checked it and triple- triple checked it. I’m not sure what im doing wrong.
    any suggestions?

    • WPBeginner Support says

      You may want to check that if your site is using https the url you have set in Google Analytics is also the same.


  19. Ally says

    Hello, I have a free account and to use the MonsterInsights or headers/footers plugins, it is requiring me to upgrade to a premium business account. Is there a way to use Google Analytics without paying for a business account?

    Thank you in advance.

  20. Merrily says

    Hi, I have tried following the steps in your tutorial, but when I try to connect to google analytics, I am constantly told that I google analytics is only available with a “g suite” email, not an email ending in But I see in your example where it says “allow monster insights to access your google account” that your sample email ends in How can I get past this to access google analytics for my site? Thanks.

    • WPBeginner Support says

      You would want to ensure you are using the same email you used to create your Google Analytics account and if you continue to have that problem, if you reach out to the plugin’s support they should be able to assist.


  21. Carrie says

    Is it okay to have the Yoast SEO plug in AND monster Insights, or should I get rid of the plug in? (I was finding it difficult anyways and don’t think I have it set up properly)

    • WPBeginner Support says

      You can use both plugins, MonsterInsights helps you see what Google Analytics is saying about your site while Yoast helps Google understand what your site is about :)


  22. Anthony says

    Is it OK to add the UA-XXXXXXXX code to BOTH the “Monster Insights” plugin – AND TO – the “All in One SEO ” plugin at the same time ?

  23. Faizan Zafar says

    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?

  24. Eric says

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

    • WPBeginner Support says

      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.


  25. Michelle says

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

  26. Tiago says

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

  27. Melanie says

    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!

  28. Tyler says

    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??

    • WPBeginner Support says

      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.


  29. zoziano says

    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!

  30. krider says

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

  31. Sagar Mandan says


    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

    Am I correct.

  32. Helena says

    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.

  33. Gabriel says

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

    • WPBeginner Support says

      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.


  34. Speaker Tim White says

    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

    • WPBeginner Support says

      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.


  35. Timo says

    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! :)

  36. Le Huu Tai says

    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

    • Joey S says

      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.

  37. majju says

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

  38. Rohit jaiswal says

    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.” ?

Leave A 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.