How to Add Google Analytics to WordPress (3 Easy Methods)

Last updated on

by

How to add Google Analytics to WordPress

If you want to accurately track the success of your WordPress website, your first step is to learn how to add Google Analytics to WordPress.

Google Analytics, currently in version GA4, is a powerful tool for making data-driven decisions that are going to help your eCommerce store or publishing site succeed. 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, I’ll 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:  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: With Google Analytics 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 profit.

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

How to Sign Up for Google Analytics

Google Analytics is available for free. All you need is a Google account to sign up. It only takes a few minutes to create a Google Analytics account for your website. Below, I’ll provide step-by-step instructions for getting started with GA4.

Step 1: Sign in to Google Analytics

Visit the Google Analytics website and click the blue Get started today button.

The Google Analytics homepage. There's a blue "Get started today" button in the upper right corner.

Next, you’ll be prompted to sign in to your Google account. If you don’t already have a Google account, click the Create account link. Otherwise, simply log in.

Sign-in page for Google Accounts

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

Webpage with the heading "Welcome to Google Analytics." There's a blue button that says "Start measuring."

Step 2: Create Your Google Analytics Account

At the top of the screen, you’ll see a progress bar with the 5 sections you’ll need to complete. The first is Account creation.

You’ll be creating the account that you’ll use to access Google Analytics. You can monitor multiple websites within a single account.

Under Account details fill out the Account name. This should likely be your business name or perhaps even your own name if you’re an independent contractor. Remember, this is the name of your account, not the individual website or app that you want to monitor.

The "Create an account" page in Google Analytics. Under "Account details," there's a field for "Account name (Required)"

Next, scroll down to Account Data Sharing Settings. Here, you’ll choose how much data you want to share with Google.

A heading says "Account Data Sharing Settings." Below is a list of setting with checkboxes that users can turn on or off.

Click the Next button at the bottom of the screen.

A blue "Next" button at the bottom of the Google Analytics Account Creation page.

Step 3. Create a Property

Now, you’ll create your Google Analytics property. Your property is the website that you want to track with Google Analytics 4.

Enter an identifying name for your website in the Property name field. Then select the timezone you want to use for reporting and your currency.

Property details in Google Analytics. There's a field for "Property name (Required)." Below, there are dropdown menus for "Reporting time zone" and "Currency."

When you’re finished, click Next.

Step 4: Describe Your Business

Now, you’ll give Google some details about your business. Use the dropdown menu to select an Industry category and select the appropriate Business size. Click Next.

The Business Details page in Google Analytics setup. There's a dropdown menu for "Industry category (Required)." Then, there are radio buttons under "Business Size (Required)." Options range from "Small - 1 to 10 employees" to "Very Large - 501+ employees."

At the bottom, there are "Back" and "Next" buttons

Step 5: Choose Business Objectives

Your next step is to select your primary business objectives. These selections help Google Analytics create more personalized reports.

Under "Choose your business objectives," there are multiple choices with checkboxes. The choices are: Generate leads, Drive online sales, raise brand awareness, Examine user behavior, and Get baseline reports

Click Create. Doing so will trigger a popup with the Google Analytics Terms of Service agreement.

Google Analytics Terms of Service Agreement popup.

To proceed through the TOS, you’ll need to:

  1. Click the checkbox beside “I also accept the Data Processing Terms as required by GDPR.”
  2. Scroll down and click the checkbox beside “I accept the Measurement Controller-Controller Data Protection Terms for the data that I share with Google.”
  3. Click the I Accept button.

Step 6: Set Up Data Collection

The final step in creating your GA4 account is to set up a data stream.

You can set up multiple data streams within your property. For instance, you might have separate data streams for your website, Android app, and iOS app.

Under Start collecting data, you’ll be prompted to choose a platform. Since we’re focusing on WordPress websites today, choose Web.

The "Start collecting data" page in Google Analytics. Under "Choose a platform," the options are: Web, Android app, and iOS app.

Now, you’ll enter your Website URL and choose a Stream name.

When you click the Create & continue button, you’ll see the Google tag code that you’ll need to add to each page of your website.

In the next section of this tutorial, I’ll show you several methods for adding Google Analytics to WordPress. You won’t need this code if you use the first method, which involves installing MonsterInsights. For the other methods, you’ll need to copy this Google Analytics tag and keep it handy.

How to Add Google Analytics to WordPress

There are many ways to add Google Analytics to WordPress. I’m going to show you the 3 easiest ways.

I’ll start with the simplest and most helpful method: using MonsterInsights.

Method 1: Connect to Google Analytics With MonsterInsights (Recommended)

MonsterInsights is the easiest and best way to add Google Analytics to WordPress websites. This premium WordPress plugin not only lets you connect your site to GA4 without any code, but it also lets you track your website data directly from your WordPress dashboard.

GA4 is a complicated beast, but MonsterInsights lets you view easy-to-understand reports without even leaving your WordPress account. You can monitor your site’s performance, user behavior, sales, and more.

An example screenshot of reports you can see directly in your WordPress dashboard by using MonsterInsights. Analytics include sessions, pageviews, device breakdown, conversion rate, revenue, and more.

You have 2 options to get started with MonsterInsights:

  1. Choose a premium MonsterInsights plan to unlock the full power of the plugin’s WordPress analytics features. If you’ve never installed a premium plugin, check out these instructions from MonsterInsights.
  2. Download the free MonsterInsights Lite plugin. However, the tracking options are very limited for the free version. If you’ve never installed a free plugin in WordPress, you can follow MonsterInsights’ instructions here.

Either way, MonsterInsights lets you easily add Google Analytics to your WordPress site, without needing to handle any code.

How to Add Google Analytics to WordPress With MonsterInsights

With MonsterInsights, you don’t have to touch any code to connect your website to GA4. Simply follow these steps.

Step 1: After installing and activating MonsterInsights, click Insights in the left menu in your WordPress dashboard. This will take you to your MonsterInsights settings. Click Launch Setup Wizard.

Screenshot of WordPress dashboard. "Insights" in the left menu is selected. The user is prompted to click "Launch Setup Wizard."

Step 2. Select your website category and click Save and Continue.

MonsterInsights setup asking which category best describes your website: Business Website, Publisher (Blog), or Ecommerce.

If you’ve purchased a paid plan, you’ll then be prompted to enter your License Key. If you’ve already entered your key or are using the free plugin, you won’t need to.

Step 3: Connect MonsterInsight to your Google account.

First, click Connect MonsterInsights.

Connect MonsterInsights button. Click this to start the process of adding Google Analytics to WordPress.

You’ll see an Authorizing message for a few moments before you see a message prompting you to connect MonsterInsights to your Google Analytics account. Click Continue & Connect to Google.

Heading says "Let's get you connected!" 
The text explains that you'll:
1. Select which account you use for google Analytics, 
2. Select which website you want the MonsterInsights plugin to use, 
3. Grant the plugin the ability to generate reports from that property.

At the bottom, there's a "Continue & Connect to Google" button.

Next, sign in to the Google account that you used to set up your Google Analytics account.

After signing in, you’ll be prompted to allow MonsterInsights to access your Google account.

Step 4: Connect Google Analytics to your website.

Because you’ve already set up your Google Analytics account and property, you’re just a couple of clicks away from connecting your WordPress site to GA4.

Use the dropdown menu to select the Property name for your website, and click Complete Connection.

And that’s it! The rest of the MonsterInsights setup wizard involves recommended settings and enabling various features. But once you’ve clicked Complete Connection, you’ve successfully connected Google Analytics with your WordPress site. You’ll be able to track your site’s analytics with MonsterInsights in your WordPress dashboard, and you’ll also be able to run full reports and explorations in GA4.

Method 2: Add the Google Analytics Tag Using the WPCode Plugin

Here’s how to add Google Analytics by adding the code to your site’s header using the WPCode plugin (formerly known as Insert Headers and Footers by WPBeginner).

Note that this method does not allow advanced tracking configurations. You also won’t be able to view Google Analytics data in your WordPress dashboard, as you can with MonsterInsights.

Step 1: Install and activate WPCode. Click Plugins > Add New Plugin, and search for “WPCode” in the search box. Click Install Now beside WPCode in the search results.

Searching for the WPCode plugin within the WordPress dashboard

After a few seconds, the Install Now button will change to say Activate. Click Activate.

Step 2: Add your Google Analytics tag to your header.

After installing and activating the plugin, click Code Snippets > Header & Footer in the left menu. You can now paste the code that you copied when you set up your Google Analytics property. Click Save Changes.

"Code Snippets" and "Header & Footer" are selected in the WordPress left menu. In WPCode, paste your Google Analytics tag into the "Header" section to add Google Analytics to your WordPress site.

Method 3: Add Your Google Analytics Tag in WordPress Theme Settings

Another way to add Google Analytics to WordPress is to paste your tag into the <head> code in your WordPress theme’s settings.

This may sound complicated, but most themes make it pretty easy.

For instance, Divi users can add their Google Analytics tag in just a few clicks.

All you need to do is click Divi > Theme Options in the left panel of your WordPress dashboard. Then select the Integration tab.

Within the Divi Theme Options, the "Integration" tab is selected. There's a code field beside "Add code to the <head> of your blog." Paste your Google Analytics tag in that field to connect your WordPress site to Google Analytics.

You’ll see an option to Add code to the <head> of your blog. Simply paste your Google Analytics tag into that code field.

Now, you’ll be able to track your website data in GA4.

Note: If you’re confident in your knowledge of PHP, you can add your Google Analytics tag code to your site’s header.php or functions.php file. However, this method can be risky, and you’ll lose your tag anytime you update your WordPress theme. I highly recommend using a plugin like MonsterInsights or WPCode, or I recommend editing the <head> code in your theme settings as a secondary option.

Grow Your WordPress Website With Google Analytics

Whichever method you choose, you’ll now be able to track the performance of your WordPress website in Google Analytics.

With MonsterInsights, you don’t have to worry about learning all of the complicated reporting in GA4. Instead, you’ll be able to view reports and data right in your WordPress dashboard!

Click here to get started with MonsterInsights, the best Google Analytics WordPress plugin on the market!

By tracking your website’s performance, you can work toward increasing your traffic. Want to convert those visitors into subscribers and customers? OptinMonster’s popups, floating bars, and other onsite campaigns help you grow your email list and make more sales!

Get Started With OptinMonster Today!

Related Resources:


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.

Popular Posts

Connect with us:

Start Getting More
Leads & Sales Today
with OptinMonster!

Popups work, and you can get started for a few bucks a month. What are you waiting for?

Create and launch smart capture forms
today in minutes. What are you waiting for?

In only 7 months, we added more than 95,654 names to our email list using OptinMonster’s Exit Intent™ technology. We strongly recommend it!

Michael Stelzner - Best Lead Generation Tool

Michael Stelzner

Founder Social Media Examiner

I hate popups, so I was hesitant to try one on my site. But the results from OptinMonster exit-intent popup speak for themselves. I doubled my subscription rate immediately without annoying my users. I haven’t had a single complaint. My only regret is that I didn’t start using OptinMonster sooner. I can only imagine how many subscribers I could have added to my email list! If you have a blog, then I highly recommend you start using OptinMonster. I’ve researched them all, and it’s the best in market.

Michael Hyatt - WordPress Lead Generation

Michael Hyatt

New York Times Bestselling Author Platform: Get Noticed in a Noisy World

Exit-intent popups have doubled my email opt-in rate. When done right, you can see an instant 12% lift on driving sales. I highly recommend that you use OptinMonster for growing your email list and sales.

Neil Patel - WordPress Popup Plugin

Neil Patel

Founder QuickSprout