How to Add Google Analytics to WordPress

Ready to start collecting visitor data?

In this tutorial, you’ll learn two ways to easily add Google Analytics to your site.

How to Add Google Analytics the Right Way

The right way to add Google Analytics is to use a plugin to add your tracking code.

Using a plugin means you can switch themes and modify your site in any way and you won’t ever interrupt the data collection. It also means you won’t have to edit any code or theme files yourself which can be problematic.

There are two plugins I recommend for adding Google Analytics to your site.

1. Google Analytics by Yoast

The Google Analytics by Yoast plugin provides an extremely easy way to add your Google Analytics tracking code to your site.

First, install & activate Google Analytics by Yoast on your site. Once activated, you’ll find a new Analytics menu item under your Dashboard link.

Visit the Settings menu (Analytics > Settings), and click on the Authenticate with your Google Account button.

screenshot of Google Analytics by Yoast settings

This will launch a popup where you can select one of your Google accounts. Make sure to select the account that is tied to your Google Analytics account for your site.

You’ll then be given a code that you can copy and paste into another popup launched by the plugin.

Popup for authenticating Google account

Once you’ve saved your code, you’re done! Google Analytics will start tracking data.

The great thing about the Yoast plugin, is that it has a host of useful features built in, and some premium upgrades that are well worth the investment.

2. Header and Footer

Header and Footer doesn’t have the extra features the Yoast plugin does, but it can be used for all of your analytics tracking codes/scripts.

Get your tracking code

The first step is to get your tracking code.

Log into Google Analytics, and click on the Admin link at the top. Then click on the “Tracking Info” link in the “Properties” column. This will reveal the “Tracking Code” link.

where to find the google analytics tracking code

Click the Tracking Code link, and copy the code in the first textarea on the next page.

Add tracking code to your site

Now that you have your tracking code, install & activate the Header and Footer plugin. Once activated, visit the new Header and Footer menu founder under Settings.

You’ll see a few tabs and textareas on the settings page. You’ll want to use the first textarea labeled, “Code to be added on HEAD section of every page.”

Paste your tracking code into that section, and save your settings.

screenshot of google analytics tracking code being added with header and footer plugin

Google Analytics will now begin tracking visitor data from your site.

The benefit of using Header and Footer is that you can repeat the same process for any other analytics software you use.

Conclusion

With the right plugins, adding Google Analytics to your site just takes a few moments.

Once it’s added, you’ll begin seeing your stats on the following day. Your dashboard will update at midnight with yesterday’s stats every day.

Related Posts