Join 1,000,000+ using SeedProd to build Landing Pages in minutes!

Get Started

How To Add Google Analytics To WordPress (The Easy Way)

Posted by Kaveri Bharali on October 9, 2020

Do you want to learn how to add Google Analytics to WordPress? Learning why people visit your site and use your content is crucial for your success.

The easiest way to learn more about your audience is to analyze your site’s statistics. And Google Analytics lets you do that for free.

In this article, we’ll share why website analytics are important and how to add Google Analytics to WordPress.

Why is Google Analytics Important?

When you create any website, one of your biggest goals is to get more website traffic and leads. Setting up Google Analytics helps you reach those goals by showing you the statistics that matter.

Let’s take a closer look at the stats recorded in analytics.

Who Uses Your Website?

Google analytics audience overview

This section of analytics tells you…

  • The geographical location of your visitors
  • The browser used to access your site
  • If they use a mobile device
  • What language they use

…and more.

This information can help you adjust your website, so it’s compatible with popular screen sizes. You can also use it to tailor your content for users in specific locations.

How People Use Your Website

Google analytics user behavior information

You can also use Google Analytics tracking to learn what people do when they land on your website. For instance, you can track how long they stay on your pages and your bounce rate. Your bounce rate is the percentage of people who exit your site on the first visit.

In this section, you can also find your top and bottom performing articles and the type of content you’re looking for.

When Users Visit Your Website

In this area of Google’s analytics dashboard, you can see which hours of the day, most people visit your site. You can use that information to plan the best times to publish your content, so more people see it.

How Users Find Your Website

Google analytics referral traffic

This section gives you details on how people got to your website. For example, did they find you via search engines, links from another website, or social media?

It’s also possible to see how many people come from each source, broken down into different categories. If people find your site from search engines, your analytics shows you which search engine gave you the most traffic.

With this information, you can figure out which traffic sources need the most work. For instance, if Pinterest is your main traffic source, you’ll need more Pinterest content to make that audience feel valued.

How People Interact With Your Content

Google Analytics also shows you the percentage of people who click your links and how they journey through your website.

With that information, you can try A/B split testing specific content to increase click-through rates and avoid tactics that don’t work.

Using analytics for your website removes all the guesswork and helps you focus on the data that matters. Then you can make data-driven decisions to improve your site and grow your business.

How to Sign Up With Google Analytics

Before you learn how to use Google Analytics with WordPress, you’ll need to sign up for a Google Analytics account.

Step 1: Visit the Google Analytics Homepage

First, go to the Google Analytics homepage to sign up.

Then, you’ll see a popup where, if you already have a Google account, you can use your credentials that to sign in.

Sign up for Google Analytics

Otherwise, click the Create Account button to start a new account.

Next, you’ll see a welcome screen giving you an overview of what an analytics account can do for your business. Click the Set up for free button to get started.

Google Analytics welcome screen

Step 2: Enter Your Account Details

The next screen asks you to enter an account name and choose your Account Data Sharing Settings. Simply click your preferred settings and click Next.

Google Analytics account data sharing settings

On the next screen, you have the choice to choose between adding a…

  • Website
  • App
  • App and website

Choose the Website option and click Next.

Add a website to Google Analytics

Step 3: Enter Your Website Details

The next screen is where you can enter the details for your site, such as your website name, URL, and more. You can track more than one website in Google’s analytics dashboard, so choose a name appropriate for each site.

Enter your website details for Google Analytics

Then enter your site’s URL, industry, timezone, and click Create.

You’ll have to accept and agree to Google’s terms and conditions next. So click I Accept to move on.

Step 4: Copy Your Google Analytics Tracking Code

After that, you’ll see a screen that includes your Google Analytics Tracking ID and Google Analytics tracking code. Go ahead and copy your tracking code, as you’ll need to add it to your website, depending on which method you use below.

Google analytics global site tag and tracking ID

It’s a good idea to leave this page open in your web browser, as you may need to refer back to it once you’ve installed the Google Analytics code on your website.

Now that you’ve set up your Google Analytics account, let’s look at how to add Google Analytics to your website.

How to Install Google Analytics in WordPress

There are several ways to learn how to set up Google Analytics on WordPress. Below we’ll show you 4 different methods. The first method is the easiest way, using a Google Analytics WordPress plugin, while the last is most difficult to achieve for beginners.

You’ll only need to use one of these methods to install Google Analytics successfully.

Method 1: Google Analytics for WordPress by MonsterInsights

MonsterInsights the best Google Analytics WordPress plugin

For the first method, we’ll be using a plugin to set up your tracking information. The best Google Analytics plugin for WordPress is MonsterInsights. MonsterInisghts is the best and easiest way to add Google Analytics to WordPress for beginners and experts.

MonsterInsights is not only the easiest solution, but it also has heaps of advantages over manual methods which are:

  • WordPress analytics reporting: Actionable data and insights within the WordPress dashboard
  • eCommerce tracking: Set up tracking for WooCommerce, Easy Digital Downloads, LifterLMS, and MemberPress with 1 click.
  • Affiliate tracking: Use Google Analytics reports in MonsterInsights to find out which affiliate links are getting the most clicks to maximize your revenue
  • Download monitoring: See how many downloads your files are getting with custom reports
  • Author stats: Find out traffic and engagement statistics for each author on your blog.
  • Advanced Tracking: with optional Addons

And you can do all this without having to know or understand how to code., which can be tricky for small business owners.

Note: MonsterInsights used to be known as Google Analytics for WordPress by Yoast. WPBeginner’s founder, Syed Balkhi, acquired the plugin in 2016 and changed it to MonsterInsights. Now it’s part of their family of premium WordPress plugins.

To set up analytics with MonsterInsights, follow these simple step-by-step instructions.

Note: There is a free version and a paid version of MonsterInsights. For this guide, we’ll be using the paid version.

Step 1: Download and Install MonsterInsights

If you haven’t already done so, you can get the Google Analytics for WordPress by MonsterInsights download here. Then save it to your computer and install and activate the plugin.

You can install the MonsterInsights plugin by navigating to Plugins » Add New from your WordPress dashboard. Then click Choose Now to find the plugin .zip file on your computer and click Install Now.

When you purchased your copy, you will have received a license key that you can view in your MonsterInsights account area.

Copy that key and add it to the blank License Key area in WordPress. Then click Verify.

install and activate the MonsterInsights plugin and verify your license key

Step 2: Connect MonsterInsights

Once your license is verified, scroll further down the page where you’ll see 2 options labeled:

  1. Connect MonsterInsights
  2. Launch Setup Wizard

For this step, you’ll need to click the Connect MonsterInsights option.

Connect MonsterInsights to install Google Analytics to WordPress

After this, you’ll go to another page where you can authenticate your Google account. Then you’ll see a message from MonsterInsights asking for permission to access your account. 

To provide access, go ahead and click the Allow button.

Click allow button

On the next page, you can select the website you’d like to collect data for.

Complete the connection to add Google Analytics to WordPress

To complete the process, click on the Complete Connection button and that’s it.

Step 3: View Your Google Analytics Reports in WordPress

Now you can check Google Analytics reports directly on your WordPress dashboard.

To do this, click on Insights » Reports from within the WordPress admin area. You’ll then see the reports right on your screen.

View your Google Analytics WordPress data with MonsterInsights

And if you scroll down your page, you can view more details, including your top referrals, top posts and pages, top countries, bounce rate, and more.

Now, there’s no more logging into other websites to view your stats. Instead, the information you need to track visitors and make informed decisions about your site is all on your dashboard.

For Google Analytics to start tracking your website visitors, you’ll need to add the code above to every page of your website. Here are some different methods to help you set up Google Analytics manually.

Method 2: Insert Headers and Footers Plugin

The next method isn’t as useful as MonsterInsights because you won’t be able to use advanced tracking, and you won’t see your analytics data in your WordPress dashboard.

First, copy your analytics tracking code that you saved when setting up your analytics account.

Copy the google analytics tracking code

Then install and activate the Insert Headers and Footers plugin on your website.

After activating the plugin, navigate to Settings » Insert Headers and Footers from your WordPress dashboard. Then in the Scripts in Header section, paste your Google Analytics tracking code.

Paste your google analytics tracking code into the scripts in header section

Finally, click the Save button. Now you’ve successfully added Google Analytics to your website!

Method 3: Add Google Analytics With Google Tag Manager

Google Tag Manager is a tag management system (TMS) that lets you manage different tags on your website. It also helps you deploy different types of code, like your Google Analytics tracking code without having to edit your website.

To add Google Analytics with Google Tag Manager, follow these simple steps.

Step 1: Create a Google Tag Manager Account

First of all, you need to sign up for Google Tag Manager and then create a new account by entering an Account Name.

New Google Tag Manager Account

Now move on to the Container Setup. Here enter your Container Name, which is your website, and select Web as your Target Platform.

Google Tag Manager container settings.

Click Create to continue.

You’ll then be asked to agree to the Google Tag Manager Terms of Service. Click Yes. Then you’ll receive the tracking codes to add to your website.

Step 2: Add the Tag Manager Snippet to Your Header

The next step is simple. Copy and paste the code snippet into your header.php file in WordPress.

To do this, simply follow the steps we explained in Method 1.

Step 3: Add a New Tag in Google Tag Manager

To get Google Analytics connected to Google Tag Manager, start by clicking New Tag.

Add a new tag in Google Tag Manager to add google analytics

You can rename your tag if you’d like to and click the Tag Configuration icon to choose your tag type.

add Google Analytics Universal Analytics to set it up in Google Tag  Manager

Then choose Google Analytics: Universal Analytics.

Choose a tag type

You’ll have to enter your Tracking ID, which we explained how to find earlier, and your Tracking Type.

For this example, let’s choose the Pageview tracking type.

Pageview tracking type

Now under the section labeled Triggering, click the icon to open up the settings.

For adding Google Analytics you’ll need to choose the All Pages page view.

add google analytics to tag manger with triggering settings

Now click Save, and you’re done!

Method 4: Add Google Analytics to a WordPress Theme

This method is for users who are familiar with editing their site’s code. However, it’s an unreliable solution because if you update your theme, you’ll lose the changes you made.

First, you’ll need to copy your analytics tracking code, then you need to add the code to your theme files. There are 2 ways to do this, which we’ll highlight next.

But before you try these methods it’s important you make sure you’re using a WordPress child theme to make these changes. Otherwise, when you update your parent theme, you could overwrite your tracking info, resulting in your global site tag being removed from your site.

1. Add the Analytics Code in Your header.php File

To do this, locate your themes header.php file by going to Appearance » Theme Editor.

Then scroll through the files until you find the right one and click to open and edit it.

Paste your Google Analytics tracking code into the file right before the closing </head> bracket, as shown below.

Where to put google analytics code in wordpress? You can add Google Analytics to WordPress by adding the code to the header file.

Then click Update File, and you’re done!

2. Add the Tracking ID to the functions.php

Another way to add Google Analytics to WordPress is to use the functions file. This will add your tracking id to every page of your website.

To locate your theme’s functions.php file, head to Appearance » Editor from the WordPress dashboard.

Then scroll through your theme files until you locate the one labeled functions.php, which is your Theme Functions.

install Google Analytics to WordPress by adding it to theme functions file

Then add the following code snippet into the file, using your own tracking ID.

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

Click Update File when you’re finished, and Google Analytics should start working right away.

Viewing Your Google Analytics Reports

Now that you’ve integrated your WordPress website with Google Analytics, you can start checking your data.

However, it takes Google a while to collect and report the information to you through the Google Analytics dashboard.

So wait for at least 48 hours before you take a look at the collected Google Analytics data.

Once the waiting period is over, you can access your data by visiting, where you can even get a glimpse of your real-time stats which you can use as part of your SEO strategy.

Some of the information you can gather includes:

  • Demographics – The age and gender of your audience
  • Geographics – Visitor languages, locations, and time zone
  • Behavior – New vs. returning visitors, frequency, and engagement

But if you’ve used the manual method, you won’t be able to see any stats in WordPress. For this, we suggest using the alternative method below.

That’s it!

If you liked this tutorial, you might want to check out our guide on how to put your WordPress site in maintenance mode so you can hide your site while making updates. And if you’d like to know how to add a contact form to WordPress, take a look at this tutorial.

And don’t forget to follow us on Twitter to see our latest blog posts.


  1. Susan Darlene Cain says:

    Thanks, John, for a very thorough and helpful post.

    1. John Turner says:

      You’re welcome :)

Add A Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Easily Create High Converting WordPress
Landing Pages with SeedProd

Get SeedProd Now