How to Set up and Use Google Analytics on Your WordPress Website

John Turner founder of SeedProd Posted by John Turner on December 3, 2015

WordPress is an excellent content management system (CMS), but it doesn’t offer a great deal of information about how users are finding your site, how long they’re staying there, where they live, what type of browser and device they’re using, and which pages on your site they like the most.

That’s why it’s important that you integrate your website with Google Analytics, a tool that provides all of that information and much more.

In this article, we’ll cover the importance of using Google Analytics, how to sign up for it, and how to integrate it with your WordPress website.

Why Google Analytics?

Having access to decent analytics is a key component in successfully growing any online property. Without it, you’re simply flying blind.

For example, wouldn’t you like to know how many people who visit your website are returning visitors as opposed to first-time visitors? Wouldn’t it be great to determine if most of your users are accessing your site from a mobile device or a traditional PC? A good analytics tool can break down that all information for you, plus a great deal more.

Google Analytics is by far the most popular analytics tool for site owners. The free version of the tool will give you more than enough incredibly detailed data on all aspects of site use to make decisions on and, naturally, it’s backed by all of Google’s considerable technical resources. Install it and you’ll get a complete picture of site traffic, demographics and how your content is performing within hours.

Signing up for Google Analytics

As with just about every other online tool, Google Analytics requires you to sign up for an account before you can use it.

Google is a big fan of the single sign-on concept. That means once you’re logged into Google for just about anything (for example, your Gmail account), Google recognizes that account for all of its other online properties.

For example, if you’re using a personal account for Gmail and you sign up for Google Analytics using that personal account, you’ve tied your website’s analytics to a personal account. That might not be how you want to do it.

Usually, it’s best to set up a separate Gmail account for your business and use that account to establish your site with Google Analytics. To do that, just click the Sign Out button from Gmail (it’s in the upper, right-hand corner) and then create a brand new account.

Also, keep in mind that Google Analytics offers you two options for accounts: free and premium. While a premium account gives you more options, it also costs money. The free version provides more than enough information for the vast majority of sites.

Once you have your new Google account, use it to create your Google Analytics account. Start by going to There, you might be asked to decide which one of your Google accounts you want to use for this Google Analytics session. Select the one that you just created. If you’re already logged in with that account, Google Analytics will just take you to the tool’s home page.

At this point, Google Analytics would normally show you a list of websites that you’re monitoring for analytics data. However, since you’re new to this, you don’t have any websites yet.

Click on the Admin menu option at the top of your screen. That will take you to a new page that will show you a drop-down box on the right-hand side below the word Account. A drop-down here should give you the option to create a new account. Go ahead and do that.

Next, you’ll find yourself on a page that allows you to enter information about your website. Most of the fields are self-explanatory. At the bottom, leave all the boxes checked that Google identifies as recommended.

Click the blue Get Tracking ID button at the bottom of the page once you’re done filling out the form. That will present you with a Google Analytics Terms of Service contract. Go ahead and click Accept on that.

Finally, you’ll be taken to the page where you can actually see your Google Analytics tracking code. That’s what you’ll need to include on your WordPress site to make Google aware of it.

How do you add that code to your website? That’s the subject of the next section.

Adding Analytics Tracking Code to Your WordPress Website

Now that you have a Google Analytics account, it’s time to get it receiving data from your WordPress site. There are several ways to go about doing that. Here are the four most popular.

1. Use a Built-in Theme Option Where Available

If you have a theme that’s been developed recently, it’s very likely that it already has a place for entering Google Analytics code. We can’t tell you exactly where to find it, because the location will vary from theme to theme. However, if you fish around your theme settings, you’ll probably come across a section that’s called “Additional Code” or words to that effect.

For example, see the screenshot below from the Old Paper theme. It clearly provides an area that’s meant for additional code and even lets you know that Google Analytics tracking code is an example of something that you’d want to add there. You’ll find that many of the modern themes provide that type of a configuration option.

Old Paper theme.

2. Use a Plugin

You can also add the Google Analytics code to your WordPress website with the help of a plugin. What you want here is a plugin that will enable you to easily add code to either the header or the footer of your website. We’ll offer a few examples here.

Insert Headers and Footers plugin.

First, the unimaginatively named Insert Headers and Footers plugin enables you to put your Google Analytics code directly into either your header or your footer. You can also use that plugin to add any additional code to your header or footer that you think is necessary for more functionality. This is a free plugin.

Header and Footer plugin

An even less imaginatively named plugin that will enable you to add code to your header or footer is called simply Header and Footer. For our purposes, it provides exactly the same functionality as the Insert Headers and Footers plugin. This plugin is also free.

If you’re using a plugin like Yoast SEO, you’ll also find options available for simply integrating your tracking code via the plugin’s settings.

3. Manually Adding Code

If you’re comfortable delving directly into WordPress template files, you’ve got the option of adding your Analytics tracking code directly into relevant WordPress files such as header.php.

That will work, but it’s not advised. Why? Because if you ever update your theme, the code you added to header.php could be overwritten. In that case, you’ll lose your analytics tracking.

If you really want to do it this way, though, just go to the WordPress back end and click on Appearance in the left-hand menu. Then, select Editor from the fly-out menu that appears.

Manually adding analytics tracking code.

Once you’re in the Editor section, click on Header on the right-hand sidebar (it will display header.php right below it) and you’ll see the code that’s included in the editor. Add the Google Analytics tracking code in there and click Update File to save.

Another way to integrate the code directly is by putting it in the functions.php file. Again, this is not necessarily the ideal way to go about things. You’d then be looking at entering code similar to below:

add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Google Analytics code goes here
<?php } ?>

Naturally, you’ll be replacing the commented line “Google Analytics code goes here” with your code.

Checking Your Data

Very rarely do we get any instantaneous gratification in this life. Google Analytics is no exception to this rule and you’ll have to wait a bit after installing your tracking code before you actually see your analytics data. It takes Google a while to accumulate and report the information. Once you’ve added the tracking code to your website, wait at least 24-48 hours before you start looking for analytics data.

When you want to check the data, you can access it at This time, the home page should show you at least one website together with some analytics data. It’s presented in table format that, by default, shows you the following metrics for the past month: the number of sessions on your website, average session duration, bounce rate, and goal conversion rate.

If you want to see even more metrics, just click on the All Web Site Data link and a wider set of possibilities opens up. Let’s briefly step through some of the more important options here.

Key Google Analytics Metrics

Once you click on All Web Site Data, you’ll be looking at the Audience Overview section of Google Analytics. If you look at the left-hand sidebar, you’ll see that it’s divided up into several sections. You enter the Audience section by default off of the home page.


The Audience section gives you access to several key metrics:

  • Sessions: That’s the number of times someone accessed your website throughout the reporting period (identified by the date range on the upper, right-hand side of the page).
  • Users: The number of people who accessed your page during the reporting period. This number is almost always lower than the number of sessions because people will (hopefully) visit your site more than once.
  • Pageviews: The number of pages that were viewed during the reporting period.
  • Bounce Rate: This is the percentage of visitors who came to your site and then left after only viewing one page. With this metric, a lower number is better. It’s a key site health indicator so it’s worth truly understanding bounce rate from the beginning.

Working out how people got to your site is another key segment of your data to get familiar with. Click on the Acquisition option on the left-hand sidebar and then the Overview link under that to start drilling into detail. Here are the basic data buckets you’ll see:

  • Direct: The percentage of sessions that came to your site directly (usually because someone has it bookmarked or typed your domain name in the URL bar).
  • Organic Search: The percentage of sessions that got to your site from a Google search.
  • Referral: The percentage of sessions that arrived at your site from a link on another site.
  • Social: The percentage of sessions that arrived at your site from a social media link.

Understanding where your traffic is coming from is a key part of being able to tell what is and isn’t working in terms of your overall marketing strategy so you’ll want to get familiar with options here sooner rather than later.

The final section to start getting familiar with is actual user behavior. Click on Behavior on the right-hand sidebar and then Overview to see the pages on your site that attract the most attention. You’ll see a table in the lower, right-hand part of the page that, by default, orders your website pages in descending order based on the number of hits. That will give you an idea of the type of content that’s most appealing to your audience so that you can produce more of it.

Wrapping Up

Google Analytics is a must have for site owners who are serious about understanding their audience and driving future growth. Follow the steps we’ve outlined above and you’ll soon be able to start swimming through a sea of data you can use to fine-tune your site and monitor results in real time.

Once the data is reliably coming in, it’ll be up to you to do some number-crunching and determine how your site can best benefit from the insights you’ll glean going forward.

Analytics is a huge subject and we’re curious to hear how you integrate it into your own sites. Are there particular key metrics you focus on? Or specific reporting techniques you employ? Get in touch via the comments and let us know!

John Turner founder of SeedProd

By John Turner

John is the founder of and a WordPress Developer with over 15 years of development experience.

Made with in Charleston, SC USA

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