How to add Google Analytics to WordPress

Measure everything

When it comes to online marketing, nothing is more important than measuring the real-world impact your efforts have on business. The gold standard for measuring an owned media property like a blog is the free version of Google Analytics. In this post, we’ll look at how to add Google Analytics to WordPress so that we can measure our blogging efforts in a comprehensive fashion.

Avoid guesswork. Use Google Analytics to get hard data.

Why Google Analytics?

Why is Google Analytics the platform of choice for so many blogs? First, it’s free of charge for all but the largest websites. While the appeal to small businesses is obvious, it can also entice larger organizations that are piloting content marketing programs.

Another reason Google Analytics is so popular is it provides robust, detailed reporting on blogs without requiring much setup.

It doesn’t take long to figure out how to add Google Analytics to WordPress, and then you’re off and running. Google Analytics is like any great application — easy to start and find immediate benefits, yet robust enough to keep delivering value as you explore it.

What do we need to install Google Analytics in WordPress?

Installing Google Analytics in WordPress requires three components:

  • A Google Analytics account
  • A Google Tag Manager account
  • A Google Tag Manager plugin for WordPress (there are many options)

These pieces combine for an installation that follows best practices — and remains robust, flexible and adaptable to future changes. While some people advocate for directly installing Google Analytics on a WordPress blog, I advise against this. It’s all too easy to create outdated tracking codes over time or have a new theme erase tracking codes entirely. The above setup provides insurance against these common mistakes.

How to add Google Analytics to WordPress

This tutorial assumes that you’ve already got a live WordPress website and domain name. We’re also assuming you have a Google Analytics account, and you want to put the tracking code on your WordPress site.

  1. Find the Google Analytics tracking code
  2. Set up a Google Tag Manager account
  3. Set up your first tag
  4. Install a Google Tag Manager Plugin
  5. Validate

Let’s get started.

1. Find the Google Analytics tracking code

From Admin, go to Property Settings, and then find the code:

Google Analytics Admin

Make note of this code in a sticky note or your computer’s notepad app. Be sure to note your website domain, as well:

Google Analytics Property Settings

2. Set up a Google Tag Manager account

Sign up for a free Google Tag Manager account if you don’t already have one. Log in, and then add a new Google Tag Manager account:

Google Tag Manager Account Setup

Select your account name, and then choose a container and your domain name:

Google Tag Manager Setup Container

Agree to the terms of service. You’ll be greeted with a snippet of code for your website. Take note only of the Account ID in the code:

Google Tag Manager Code

3. Set up your first tag

Set up your first tag by clicking New Tag:

Google Tag Manager New Tag Creation

Name the tag, then click the grey icon to begin adding the tag:

Google tag Manager Tag Name

Select Universal Analytics:

Tag Type with Universal Analytics

Name this tag something obvious, like Google Analytics. From Google Analytics Settings, go to Select Settings Variable, and then select New Variable:

Google Analytics Settings Variable

Paste your Google Analytics ID (the code you got earlier, which begins with UA-) into the Tracking ID field, then click Save:

Tracking ID

Click Choose a trigger to make this tag fire:

Google Tag Manager Choose Trigger

Select All Pages:

GTM All Pages

Click Save. When you’re done, click Submit on the container’s main page:

GTM Submit Tag

Create some reference notes, and then click Publish. This completes the process for creating a tag with Tag Manager:

GTM Publish Tag

4. Install Tag Manager Plugin

Let’s move on to the final stage of the process, installing Google Tag Manager on your WordPress blog.

From your WordPress control panel, go to Plugins, and then click Add New Plugin:

WordPress New Plugin Menu Option

In the Keyword field, enter Google Tag Manager, and then choose the plugin from either DuracellTomi or George Stephanis:

WordPress.org Plugin Repository

From Settings, go to Google Tag Manager, and then note the options. Paste in the Google Tag Manager code you got earlier (which begins with GTM-), and then make sure the top boxes are checked. Scroll down to the bottom of the page and click Save.

Google Tag Manager WordPress Options

5. Validate

To make sure everything is working correctly, open Google Analytics, and then from the REAL-TIME section, select Overview:

Google Analytics Realtime Visitor Data

You’ve just about figured out how to add Google Analytics to WordPress. To wrap things up, go online with another device, such as your smartphone, and then open your website. Go back to Google Analytics on your original device. You should see at least one new active user in the real-time overview, indicating that everything is working correctly.

A quick recap of how to add Google Analytics to WordPress

If you again find yourself wondering how to add Google Analytics to WordPress, remember the process we just covered. It ensures you have the most modern, up-to-date version of the software, and a robust way to make future changes. As you likely saw with Google Tag Manager, many other options are available. Once you have it installed, making changes is straightforward.

For example, using the free Google Optimize software, you could A/B test landing pages on your website with Google Analytics and Google Tag Manager. You’ve already completed most of the installation steps to do so.

You could use Google AdWords to run ads for your business and track conversions. And again, with the setup we just covered, you’ve already handled the majority of the nuts-and-bolts infrastructure needed to track it. All that’s left to do is add the AdWords tracker in Tag Manager.

Good luck measuring your WordPress blog!


Find out more about GoDaddy’s WordPress Hosting plans.

Need help with Google Tag Manager or Google Analytics? Ask other GoDaddy users for help in the community.


Also published on Medium.

Christopher S. Penn
VP of Marketing Technology at SHIFT Communications, Christopher S. Penn is an authority on digital marketing and marketing technology. A recognized thought leader, author and speaker, he has shaped three key fields in the marketing industry: Google Analytics adoption, data-driven marketing and PR, and email marketing. Known for his high-octane, here’s how to get it done approach, his expertise benefits companies such as Citrix Systems, McDonald’s, GoDaddy, McKesson and many others. His latest work, Leading Innovation, teaches organizations how to implement and scale innovative practices to direct change. You can find him on Facebook, Twitter, LinkedIn and Instagram.