How to Add Google Analytics to WordPress (in Under 5 Minutes)

Are you looking for an easy way to add Google Analytics to WordPress?

Analytics can be a scary word to some people, but it doesn’t have to be! In fact, analytics tools like Google Analytics make it super easy to make the data-driven decisions that are going to help your eCommerce store or publishing site succeed. In this article, we’re going to show you how to add Google Analytics to your WordPress site.

If you’ve ever been intimidated by Google Analytics in the past, don’t worry! We’re with you every step of the way.

In this article, we’re going to show you how to add Google Analytics to your WordPress site.

Here’s an overview of what you’ll learn in this post:

Let’s get started.

Why Is Google Analytics Important?

Google Analytics is a free, comprehensive analytics solution for your website.

Understanding your website analytics is key to growing your site’s traffic. That, in turn, leads to increased subscribers and then, to boosting revenue.

With Google Analytics on your website, you’ll be able to track all of the data that you need to get actionable insights to grow your business, eliminating the question of what you should be doing.

With Google Analytics, you can get site statistics like:

  • Number of website visitors
  • Where visitors are coming from (referral links)
  • What content on your site is most popular
  • And a ton more

So, why is Google Analytics important?

Here are some of the ways Google Analytics helps improve your business marketing strategy:

  • Learn More About Your Visitors: Using Google Analytics for WordPress helps you track and collect information about your visitors. The more data you have, the more you can personalize your content marketing strategy.
  • Understand How Visitors Interact With Your Content:  Adding Google Analytics to WordPress lets you track what your visitors are doing while they’re on your site. You’ll be able to see things like what pages they visit, how long they stay on your website, what pages they stay on the longest, and more.
  • Discover How Visitors Find Your Website: Having Google Analytics on WordPress also gives you essential tracking info about how visitors find your site in the first place.
  • Troubleshoot When Things Go Wrong: When you add Google Analytics to WordPress, you’ll have all your site’s data at your fingertips. If you notice any abnormalities in traffic or sales, you can fix those problems much faster and reduce unnecessary losses.

The bottom line is that when it comes to digital marketing, knowledge isn’t just power; it’s also profits.

Now let’s turn our attention to how you can sign up for Google Analytics in the first place.

Then we can look at how to add Google Analytics to WordPress in under 5 minutes.

How to Sign Up for Google Analytics

Google Analytics is available for free. All you need is a Google or Gmail account to sign up.

If you don’t have a Google account at all, then this is the first place to start. If you already have an account (like a Gmail or YouTube account), just skip over the first step and start at Step 2.

Step 1: Create a Google Account

You need to have a Google account to use Google Analytics. If you already have a primary Google account like Gmail, YouTube, or Google Drive, you’ll want to set up your Google Analytics account under the same name.

Otherwise, you’ll need to create a new one.

Step 2: Sign Up for Google Analytics

Once you have a Google account, you’ll need to sign up for Google Analytics. Click the Start for free button.

create google analytics account

You’ll then be prompted to log into your Google account that you created in Step 1.

After you’ve signed into your Google account, click the Start measuring button on the next screen.

start measuring google analytics

Then, enter the account name for your Google Analytics account and check off all of the boxes in the Account Data Sharing Settings section. Click Next to continue.

google analytics data sharing

The next step is to enter the property details of your website including a name, reporting time zone, and currency. When you’re finished click the Show advanced options button.

google analytics show advanced options

Now, enable the Create a Universal Analytics property option:

enable universal analytics property

After that, you need to enter the URL of your website and be sure to select the Create a Universal Analytics property only option. Otherwise, you might face issues connecting to other tracking platforms like MonsterInsights.

select create universal analytics property only

You’ll then be asked to enter other details about your business like the industry, the size of your business, and how you intend to use Google Analytics for your business.

add business information to google analytics

When you’re done, click the Create button.

You will then be asked to accept the Terms of Service. After you hit the I Accept button, you’ll be taken to a screen where you can see your Tracking ID and tracking code.

google analytics tracking ID

We recommend leaving the Google Analytics browser window open since you may need it depending on which method you choose to add Google Analytics to your WordPress site.

How to Add Google Analytics to WordPress

There are many ways to add Google Analytics to WordPress. Let’s take a look at them below:

  • Install Google Analytics on your site using MonsterInsights (Recommended)
  • Add the raw tracking code to your site’s header with a plugin
  • Manually add the tracking code in header.php
  • Manually add the tracking code in functions.php

We will start with the simplest method and end with the toughest option.

Method 1: MonsterInsights

The MonsterInsights plugin for WordPress is the best way to add Google Analytics to your website. With MonsterInsights, you can view your website data in easy-to-understand reports from your WordPress dashboard.

And setup is super easy with no code required.

MonsterInsights Google Analytics plugin for WordPress

MonsterInsights is the easiest (and by far the best) way to add Google Analytics to WordPress websites. It’s a premium WordPress plugin that’s by far the most user-friendly way to track your site.

This Google Analytics plugin has everything you need to monitor your site’s performance, user behavior, how many sales you’re generating, and more, right from your WordPress admin dashboard.

That means you won’t need to hire a developer or have any baseline of “tech skills.” It’s what makes this tool the perfect solution for small businesses, bloggers, and solopreneurs.

You’ll get real-time data to stay up to date, and you can monitor what marketing campaigns are having the highest (and lowest) impact. This includes tracking pay-per-click (PPC) ad campaigns on AdSense and other PPC platforms (including social media).

You’ll even be able to monitor your key SEO metrics to ensure you’re getting higher up in the rankings. This is especially true since you can integrate Google Search Console for even more data about your site’s performance.

Or track how many contact form submissions you have and what pages they take place on and various events with Google Tag Manager.

With MonsterInsighs, your data-collecting possibilities are nearly endless.

And with a WooCommerce integration, you can stay focused on what really counts for your business’s growth: driving more sales from your online store.

It’s why 3,000,000+ users agree that MonsterInsights is the BEST WordPress plugin for Google Analytics.

MonsterInsights also seamlessly connects with Universal Analytics and Google Analytics 4 (GA4). You can connect to whichever version you’re running or connect to both at the same time with the Dual Tracking feature.

To add Google Analytics to WordPress using the MonsterInsights plugin, go to Plugins » Add New from your WordPress menu.

Search for MonsterInsights and when the plugin shows up, click Install Now then, Activate.

search for the monsterinsights plugin

Go to Insights » Settings to authenticate your blog with Google Analytics.

connect monsterinsights

Click the Connect MonsterInsights button.

On the next screen, select your Google account.

connect google account to monsterinsights

Next, allow MonsterInsights to manage your account by clicking the Allow button.

Finally, select the correct website profile for your blog and click Complete Connection.

select website to connect to monsterinsights

After activation, the plugin will add a new menu item called Insights to your WordPress menu. Clicking on it gives you access to your reports and insights.

That’s it! You now know how to add Google Analytics to WordPress in under 5 minutes! It will take Google Analytics a bit of time before showing your stats (typically 12-24 hours, but sometimes up to 48).

If you have a Universal Analytics property and a GA4 property, you can also set up dual tracking with MonsterInsights.

To set up dual tracking, go to the main Settings page. Then, scroll down to Google Authentication and find the Dual Tracking Profile box.

Now you can enter your Universal Analytics Tracking ID or your GA4 Measurement ID, whichever one you didn’t authenticate in the initial setup.

dual tracking with monsterinsights

With dual tracking, you can bring in all of your historical data from Universal Analytics and access the new features of GA4 at the same time.

Looking for another way? Let’s look at our second method for adding Google Analytics to your WordPress site.

Method 2: Insert Headers and Footers Plugin

Here’s how to add Google Analytics by adding the code to the header of your site using the Insert Headers and Footers plugin.

After installing and activating the plugin, go to Settings » Insert Headers and Footers and paste the Google Analytics tracking code into the plugin’s settings.

add google analytics tracking code to insert headers and footers

Remember that you won’t be able to do advanced tracking configurations with this method. And, you won’t be able to view Google Analytics data in your WordPress Google Analytics dashboard.

Method 3: Manually Add Google Analytics Code in header.php File

A more complex way to add Google Analytics to WordPress would be to add the global tracking tag to the WordPress theme using the theme editor.

To do that, open your theme’s header.php file and place the code just before the closing </head> tag.

If you add the code snippet to your main theme, then it will be overwritten whenever you update your theme. We strongly recommend using a child theme when adding customizations to your WordPress site.

Trying to modify the parent theme leaves you more vulnerable to technical issues if you’re not an experienced developer. And by breaking these theme files, you risk losing valuable data from your website.

Method 4: Insert Analytics Code in functions.php File

If you’re confident in your knowledge of PHP, you can open your theme’s functions.php file and add the following code, replacing the fourth line with your Google Analytics code:


&lt;?php add_action('wp_footer', 'add_googleanalytics'); function add_googleanalytics() { ?&gt;

// Paste your Google Analytics code here

&lt;?php } ?&gt;

Now you know 4 different ways to add Google Analytics to your WordPress site!

While we firmly believe in your ability to use any of these methods to add Google Analytics to WordPress successfully, only MonsterInsights makes it super simple to set up advanced tracking and view reports from the comfort of your WordPress dashboard.

We hope you enjoyed this tutorial. If so, then you might find these resources useful:

Now, you’re ready to get the most out of Google Analytics on your WordPress site.

Still not signed up for MonsterInsights? What are you waiting for?

Click here to get started with the best Google Analytics WordPress plugin on the market. 

Jacinda Santora
Jacinda Santora is a writer specializing in eCommerce and growth marketing. She prides herself on her ability to make complicated things easier. When she isn't writing you can find her daydreaming about campervans, drinking coffee, and listening to podcasts.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. We only recommend products that we believe will add value to our readers.

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.