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

Posted by Kaveri Bharali on August 22, 2019

Last updated on: January 17, 2020

Want to know how to add Google Analytics to WordPress easily?

Google Analytics is by far the most popular analytics tool for most website owners. It’s a great way of keeping track of your website traffic and getting detailed insights into your visitors and their behavior. Best of all, it’s free.

Using this data, you can take all the necessary steps to improve your business and maximize your profit.

Besides, you can completely rely on this data because it is backed by all of Google’s considerable technical resources.

Adding Google Analytics to WordPress

In this tutorial, we’ll show you 4 different ways you can learn how to add Google Analytics to WordPress:

  1. Add Google Analytics with MonsterInsights (the easy way)
  2. How to Add Google Analytics without a plugin
  3. Add the Google Analytics tracking code to your WordPress theme
  4. Install Google Analytics with Google Tag Manager

Just click the method you want, to skip ahead.

Once you connect your Google Analytics account to your WordPress site, you’ll get a complete picture of your site traffic, demographics, how your content is performing, and much more.

Ready to connect your site? Let’s get started.

Method 1: How to Add Google Analytics With MonsterInsights (The Easy Way)

MonsterInsights is the best Google Analytics plugin for WordPress.

MonsterInsights is not only the easiest way to add Google Analytics to WordPress, but it also has 2 important advantages over the manual method:

  1. You can see actionable analytics reports right in your WordPress dashboard.
  2. Google Analytics can be configured easily to track more advanced data (like eCommerce tracking), without having to code.

Let’s take a look at how easy it is to set up Google Analytics in WordPress with MonsterInsights.

Step 1: Sign up for Google Analytics

Just like any other online tool Google Analytics requires you to sign up for an account before you can start using it.

To do this just log in to your Google Account and then go to the official Google Analytics site and click the Start for free button.

Create an account to add Google Analytics to WordPress

From there, follow the account signup process where you can start by choosing if your property is a website or a mobile app.

signup for Google Analytics

Then proceed by adding your account name, website/app name, and your website URL. You can also add your industry category, and add your time zone for accurate tracking.

Step 2: Set Up MonsterInsights

For the next step, you’ll need to log in to your WordPress dashboard.

If you haven’t downloaded MonsterInsights yet, download it here. Then install and activate it like any other plugin.

The next step is to verify your license key that you’ll get at the time of downloading the MonsterInsights plugin.

Just copy the key and paste it into the blank field after you install the plugin and it will automatically verify your license.

install and activate the MonsterInsights plugin and verify your license key

Once your license is verified, scroll further down the page where you’ll see 2 options. Then click on the Connect MonsterInsights option.

Connect MonsterInsights to install Google Analytics to WordPress

After this, you’ll be redirected to another page where you can log in to your Google account using your business account.

Then you’ll see a message from MonsterInsights asking for permission to access your account. So to provide access, click on the 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.

Now you can view your 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 data in WordPress with MonsterInsights

And if you scroll down your page you can view more details.

So now, there’s no more logging into other platforms to view your stats. Instead, you can check it right from within WordPress with MonsterInsights.

And if the bounce rate on your analytics turns out to be high like ours, here’s how you can reduce it.

The Best Google Analytics Plugin for WordPress

MonsterInsights is the best Google Analytics Plugin for WordPress but if you need even more features for tracking your website data, here’s what else you track:

  • eCommerce Tracking. Set up tracking for WooCommerce, Easy Digital Downloads, LifterLMS, and MemberPress with 1 click.
  • Affiliate Link Tracking. Find out which affiliate links are getting the most clicks so you can maximize your revenue.
  • File Download Tracking. See how many downloads your files are getting (no code needed).
  • Author Tracking. Find out traffic and engagement statistics for each individual author on your blog.

…and lots more! See all of MonsterInsights’ features here.

If you’re comfortable with coding and would prefer to manually track some basic stats, without those advanced reports, you can use the manual way instead which doesn’t require a WordPress plugin.

Here’s how it works…

Method 2: How to Add Google Analytics Without a Plugin (Manually)

After you set up your Google Analytics account (as we walked through above) here’s how you install Google Analytics to WordPress manually without a plugin.

Step 1: Get Your Google Analytics Tracking Code

Once you are done with Step 1, you need to scroll down while on the same page to find the Get tracking ID option.

When you’ve located it just click to proceed and then check the Google Analytics terms box.

You should now be on your Google Analytics dashboard which looks something like the image below. And you can see your Tracking ID right on top of the page.

To learn how to add Google Analytics to WordPress, head to the Google Analytics dashboard

Now that you have your ID, it’s time to get your Google Analytics account connected to your WordPress website.

To do this, start by clicking on the Admin sign on the bottom left corner of your screen.

Go to the Admin section of your Google Analytics dashboard

After this, you’ll be redirected to a new page. On this page, click on Tracking Info » Tracking Code under the property column.

Find the tracking info in your Google Analytics dashboard

You should now copy the entire code that is visible on your screen. This is available under the Google Site Tag option.

Copy the  tracking code to add Google Analytics to WordPress

The next step is to log in to your WordPress dashboard and copy this code so you can add the code to your website header. Let’s see how to do that.

Step 2: Add Google Analytics by Adding the Code to the Header

To add your Google Analytics code manually to your site header, you’ll need to edit your themes’ header.php file.

But if you go down this route, it’s important you add the code to a WordPress child theme rather than your main (Parent) WordPress theme. This is because your tracking code is overwritten in the parent theme every time you update the theme files.

Where do I put the tracking code in WordPress?

Since Google analytics recommends that you paste the code in the Header section, you’ll need to locate your themes header.php file by going to Appearance » Editor.

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

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

You can add Google Analytics by adding the code to the header file.

Then click Update File and you’re done! You’ve now installed Google Analytics on your WordPress website without having to use a plugin.

Method 3: Add the Tracking Code to the WordPress Theme

It’s also pretty easy to add Google Analytics to your WordPress theme if you prefer. You do this by adding the tracking ID to your theme’s functions.php file.

To add your tracking code to the WordPress theme follow these steps.

Step 1: Get Your Google Analytics Tracking ID

For this method, instead of copying the tracking code, you’ll need your Tracking ID which you can find under Tracking Info » Tracking Code in your Google Analytics dashboard.

Copy your Google Analytics Tracking ID from the tracking info section

So go ahead and copy your tracking ID and move on to the next step.

Step 2: Add the tracking ID to the functions.php file.

To locate your theme’s functions.php file, head to Appearance » Editor from the WordPress dashboard and 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 instead of ours.


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

Method 4: 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’s code.

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.

Copy and paste the code snippet into your header.php file as we explained earlier.

Step 2: 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. Then choose Google Analytics: Universal Analytics.

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

You’ll have to enter your Tracking ID, which we explained earlier, and your Tracking Type. For this example, let’s choose Pageview.

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!

Step 3: Analyze Your Data

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 its dashboard.

So wait for at least 48 hours before you start looking for your Google Analytics data after you’ve added the tracking code to your website.

Once the waiting period is over, you can access your data by visiting where you can even get a glimpse of your real time data. If you’ve used the manual method, you won’t be able to see any stats in WordPress.

That’s it! If you liked this tutorial, you might want to check out our tutorial on how to put your WordPress site in maintenance mode.

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

Made with in Charleston, SC USA

Copyright © 2020 SeedProd LLC
Terms & Conditions | Privacy Policy | SeedProd Coupon Code