August 04, 2022
How to add Google Analytics to WordPress

Have you ever wondered about your audience? Wanted to know where visitors to your website lived? How old they were? Google Analytics (sometimes referred to as just “GA”) can help you better gauge visitors and make informed, data-driven decisions regarding your website.

Keep reading to learn how to add Google Analytics to WordPress.

What Is Google Analytics?

Google Analytics uses a web beacon to gather and collate data about visitors to your site. This free-of-charge service by Google enables you with the tools you need to sift through that data and understand how your customers behave while they visit your website. Google Analytics also offers insights into how you can provide a better customer journey and customer experience.

What Can Be Tracked in Google Analytics?

You may be asking yourself, “If I connect Google Analytics to WordPress, what can be tracked?” Here are just a few of the things that can be tracked.

Geographical Data

Google Analytics can allow you to see where your customers are. You can view by city, by country, by continent, and by subcontinent.

Add Google Analytics to WordPress to get geographical data

Source of Traffic

If you’ve ever wondered, “How did my customers find me?” Google Analytics will help you. Here are a few types of traffic you can find in Google Analytics.

  • Direct Traffic — These are visitors who manually typed in your address (or, more likely, clicked on a bookmark).
  • Search Traffic — These are visitors who searched for something using Google and clicked on your site in the search results.
  • Referral Traffic — These are visitors who arrived at your website by following a link to your website from some other website.


Are your customers viewing your site by using their cell phones or their desktop computers? Are they using Safari or are they using Chrome? Google Analytics answers these questions.

Event Tracking

Once you’ve added Google Analytics to your WordPress site, you will be able to track events. We have an article that more fully explains event tracking but here’s a quick run-down of just a few types of web events that can be tracked:

  • Page events using the mouse (e.g., where a visitor clicked on your site).
  • Keyboard events (e.g., what a visitor typed into frames and forms on your site).
  • Frame events (e.g., when a visitor scrolls through a frame).
  • Form interactions (e.g., when a user adds payment information or proceeds to checkout).

Page Views

How many pages did each visitor view? What was the average number of views across all visitors?

Session Duration

Closely related to Page Views is Session Duration. How long was each visitor viewing your site?

Exit Pages

What page was a viewer last viewing when they left your site?


Google Analytics helps you track conversions. Conversions are when visitors to your site perform an action you value, such as subscribing to your mailing list or confirming a purchase. This is about converting random site visitors into loyal customers and clients, and turning clients and customers into dedicated fans.

Adding Google Analytics to WordPress gets you acquisition data on site visitors


This is related to sources of traffic. Google Analytics helps you turn insights into results. In particular, by linking the Google Ads and Google Analytics accounts for your website, you can track which Google Ad Campaigns were most successful in bringing visitors to your site, your cost per acquisition, and how much each site conversion costs.


Your website is your store window. Formerly known as “Content Experiments,” this feature of Google Analytics has been expanded and migrated to Google Optimize. You can leverage Google Analytics with Google Optimize to better understand split-tests for your WooCommerce site.

That’s a very, very brief introduction and broad overview of what Google Analytics can track. For guides, videos, and demos, head over to the official Google Analytics developer portal.

Why Is Google Analytics Important?

From reading the above list, you’ve probably already gleaned a few ideas you could use and are maybe now wondering how to add Google Analytics to WordPress. If not, here are a few more suggestions for why you should connect Google Analytics to your WordPress or WooCommerce site.

All in one WordPress solutions


As suggested above, Google Analytics “just works” with most other Google platform services. If you have a Google Play app, you can use GA to track the Google Play Referral Flow from your associated WooCommerce site. If you have an active AdWords campaign with an email campaign component, you can align that data to track what’s working and what isn’t.


Whether it’s a new sale or a new subscription, a new conversion is a delight. Whether you’ve had a managed WooCommerce site with us for years, or you’ve just decided to create your first online store, knowing why you gained a conversion is true bliss.

Imagine you’ve just got an unexpected rush of new conversions. Was it that new AdWords campaign? Did your latest Facebook campaign bring in those new clients? Or maybe it was the funny tweet from your college intern? Attribution (now in beta) from Google Analytics will help you stop wondering and start smiling as you better model the attribution for your conversions.


Recognizing shifts in your website traffic and conversion rates spotlights new opportunities and helps you better focus your marketing efforts. For example, Google Analytics will help you break down which social media platforms are just bringing in new traffic and which platforms are now also bringing new conversions.

How to Signup with Google Analytics

Simply follow the instructions on the Google Analytics new account page. They won’t tell you how to add Google Analytics to WordPress, but they will ask some questions about your website and what types of data you’re interested in tracking.

Though entirely optional, you’ll probably want to also sign up for a Google Tag Manager account. Google Tag Manager helps you handle and unify the different tags and beacons across all the Google services (e.g., Analytics, AdWords, Play, etc.) and 3rd-party tags (e.g., AdRoll, AdAvisor, Twitter, etc.).

How to Install Google Analytics Using Headers and Footers Plugin

After you’ve created a Google Analytics account and created at least one tracking code, you’ll want to know how to add Google Analytics to WordPress. To enable Google Analytics to start collecting data, you’ll simply add the tag from Google Analytics to the headers (or footers) of your WordPress site.

One easy way to add the newly created tracking code is to use the Insert Headers and Footers plugin.

Step 1: Install and activate the plugin. If you have one of our Managed WordPress or Managed WooCommerce plans, you can use the Nexcess Plugin Installer.

Step 2: Insert code in your header or footer by going to the Settings > Insert Headers and Footers menu.

Step 3: That’s it! Google Analytics wil now start collecting data.

Use the Insert Headers and Footers plugin to add Google Analytics to WordPress

How to Install Google Analytics in WordPress

After a few days, Google Analytics will have enough data collected to begin offering you insights. Unfortunately, the official Google Analytics dashboard offers you so much data and ways of looking at the data that it collects, it can feel a little like drinking water from a firehose. Many many first-timers to GA will find a Google Analytics WordPress plugin essential to not feeling overwhelmed.

Unfortunately, there isn’t an official WordPress plugin for Google Analytics. There is, however, an official plugin for WooCommerce called WooCommerce Google Analytics. Fortunately, there are quite a few 3rd-party plugins available. One such plugin is the MonsterInsights plugin.

Monster Insights can help you install Google Analytics on WordPress

Whichever plugin you choose, the installation instructions will be similar to the MonsterInsights installation instructions. The plugin will have a settings section where you can link the plugin to your Google Analytics account. This will redirect you to your account with Google where you will be informed there is a 3rd party app (your new plugin) requesting permissions to access your account. Click ‘Allow’ if you want the new plugin to help you with your Google Analytics data.

That’s it! Now you know how to put Google Analytics on a WordPress website.

Making the Most Out of Google Analytics

Whether you’re trying to start a new fan-club or start a new online business, you’ll want to make the most out of Google Analytics.

Narrow Focus — It’s easy to get distracted by the many, many metrics offered by Google Analytics. Have a set of just 5-10 indicators that are key to accomplishing your goals. Focus on those.

Regular Review — You’ve invested your valuable time into identifying your key metrics and designing custom reports for them. Now, remember to read the reports. You’ll want to review them weekly. Review daily if you’ve recently updated your site or launched a new campaign.

Make Changes — You’ve identified your KPI, you read the reports based on them, now use them. Have you seen almost no change in your metrics since your latest AdWords campaign launched? Try changing your campaign keywords. Google Analytics can be a roadmap to success. When you realize you’re driving down the wrong road, you should change roads.

Google Analytics is incredibly powerful, it’s free, and it’s super easy to install Google Analytics on your WordPress site. What are you waiting for?

Get Fully Managed Hosting From Nexcess

While you focus on getting Google Analytics set up on your WordPress website, we’ll worry about everything else. That’s the beauty of managed WordPress hosting. Check out our hosting plans to get started today.

Michael Pruitt
Michael Pruitt

Michael Pruitt is a Support Systems Administrator for Nexcess. He brings over a decade of experience to his current role. When not working, Michael can be found officiating roller derby bouts.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.