X

How to Install Google Analytics on Your WordPress Site

Do you want to install Google Analytics on your WordPress site?

Adding Google Analytics to your WordPress is the best way to track how your visitors are interacting with your website. In this article, we’ll show you how to install Google Analytics on your WordPress site in 2 simple steps.

Before we jump into adding Google Analytics to your WordPress site, let’s examine what Google Analytics is, why it is important and how it works. If you’d rather cut straight to the chase and dive into the step-by-step Analytics installation process, then go for it.

What Is Google Analytics?

Google Analytics is the most comprehensive tracking tool for your website that allows you to see where your visitors are coming from, what they do on your site, which content is popular, and so on.

It gives you a better understanding of your marketing impacts by providing easy to understand stats. Whether you’re a publisher, small business owner or an eCommerce merchant, Google Analytics provides you with everything you need to know about your visitors.

Aside from basic visitor engagement stats, some of the Google Analytics tracking features you’ll find useful are:

  • Ads tracking
  • Enhanced eCommerce tracking
  • Events tracking
  • Online forms tracking
  • And a lot more

Why Is Website Analytics Important?

Understanding your website visitors is the key to grow your traffic, subscribers and revenue. By installing Google Analytics on your WordPress site, you can gather all your website data, which provides actionable insights to grow your business. This way you can eliminate guesswork and start making informed decisions based on the data you’ve gathered.

Below are a few benefits of tracking your website visitors using Google Analytics.

Get to Know More About Your Visitors

You can collect and track visitor information such as geographical location, demographics and interests, device and browser they used while browsing your site, and a lot more. These data help you better understand your audience, so you can better craft your marketing messages in a way that best resonate with them.

For example, if you find that most of your website visitors are female based in the US, you can curate content addressing the need of that specific user base.

Understand How Visitors Interact With Your Website

You can also track details like what your visitors do while they are on your website, how long they stay on your site, etc. With the help of these data, you can come up with strategies to make them more engaged, keep them longer and even convince them to make purchases on your site.

Understand From Where Your Visitors Arrive

Google Analytics gives you the breakdown of different traffic sources such as search engines, social, referrals, direct traffic, etc. By analyzing your traffic sources, you can understand which source contributes the most visitors to your site.

It can also give you insights into how to increase your website visitors.

For example, if your top referral source is an external website, then you might want to consider having a partnership with that website such as submitting guest posts.

How Does Google Analytics Work?

To be able to track your visitors’ data, you need to implement a piece of tracking code on your website that you obtain from your Analytics account. The tracking code must be added on every page on your website. This can be done by adding the code right into the header section of WordPress.

Whenever someone arrives at your site, they are tagged by the tracking code in their browser and then their session on your website begins.

Installing Google Analytics on your WordPress website is pretty easy. All you have to do is install a Google Analytics plugin such as MonsterInsights and configure it with Analytics. Alternatively, you can manually add the tracking code on your site but the downside is that it will limit your ability to enable enhanced Google Analytics tracking features.

In this article, we’ll explain how to add Google Analytics tracking to WordPress both via MonsterInsights and manual methods.

Step 1: Sign Up for a Google Analytics Account

The first thing you need to do before installing Google Analytics is to sign up for the service. Google Analytics is available for free, so all you need to do is to visit Google Analytics and sign up with your Google account.

In the upper right hand corner, you can find the Sign In dropdown menu. Simply click on it.

how to install google analytics

You’ll be prompted to choose from different Analytics solutions. As we want to sign up for Google Analytics, click Analytics.

click on analytics

This will direct you to a page where you’ll be asked to sign in with your Google Analytics account or sign up for a new Google Account.

sign into analytics

After you’ve signed in to your Google account, you’ll need to sign up for Google Analytics. Click the Sign Up button on the right side of the page to get started.

google analytics signup

Next, you’ll need to enter the settings for the site you want to start tracking. Make sure the Website option is selected at the top.

GA track website

Then you need to scroll down to enter your website information. You’ll also need to name your Google Analytics account, and enter your website name, URL, and industry, as well as your time zone.

ga account setup

Fill in the info needed to create a Google Analytics account.

After filling in your website details, you can scroll down a bit to customize your data sharing settings. When you’re finished selecting your options, you can click the Get Tracking ID button at the bottom of the page.

get analytics tracking id

In the popup window that appears, you can review and accept the terms of service.

accept google analytics terms of service

That’s it! You’re now signed up for Google Analytics.

Step 2: Install Google Analytics in WordPress

Now that you’ve signed up for Google Analytics, the next thing you need to do is to add Analytics to your WordPress site. There are many ways to add Google Analytics to WordPress. Let’s take a look at them below.

  1. Install Google Analytics on your site using MonsterInsights (Recommended)
  2. Add the raw tracking code to your site’s header with a plugin
  3. Manually add the tracking code in header.php
  4. Manually add the tracking code in functions.php

MonsterInsights vs. Manual Google Analytics Installation

Before we dive into Google Analytics installation process, it’s worth taking a moment to examine why using the MonsterInsights plugin is recommended over manual Analytics installation.

For some users, installing Google Analytics might seem like a no-brainer task. For that reason, they manually add Analytics tracking code to their site without using any plugin.

While manually installing Google Analytics allows you to gather basic traffic stats like sessions, pageviews, bounce rate, etc., the downside is that it doesn’t allow you leverage the full potential of Google Analytics.

For example, if you need to make use of more Analytics tracking features like download tracking, link tracking, forms tracking, ecommerce tracking and more, you’ll have to manually customize the code for every instance. Without a doubt, this can be tedious especially if you’re not a developer or an Analytics expert.

Chances are, even a slight mistake can skew your entire Analytics tracking, meaning you get wrong data in your Analytics account, which even leads you to make wrong decisions for your business.

MonsterInsights

On the other hand, MonsterInsights makes it super easy to install Analytics with just a few clicks. MonsterInsights is the most popular Google Analytics plugin for WordPress in existence. To enable enhanced tracking features, all you have to do is to make a few clicks or install the respective addons.

As you’d never need to touch a single line of code, it saves your precious time during the entire installation process.

Get started with MonsterInsights today to easily set up Google Analytics on your site.

Want to start with the free version instead? Try MonsterInsights Lite.

Method #1. Install Google Analytics on Your Site Using MonsterInsights (Recommended)

To set up Google Analytics on your site, subscribe to a MonsterInsights plan and download the plugin. If you’d rather start with the free plugin, head over to Plugins » Add New. Search for MonsterInsights and when the plugin shows up, click Install Now and then, Activate.

install monsterinsights

Head over to Insights » Settings to authenticate your blog with Google Analytics. Click Authenticate with your Google account.

click authenticate with your google account

On the next screen, select your Google account.

choose a google account for analytics

Next, allow MonsterInsights to manage your account.

allow monsterinsights to manage analytics

Finally, select the right website profile for your blog and click Complete Authentication.

authenticate monsterinsights

After authentication, you can easily find how your website is doing by visiting Insights » Reports.

wordpress google analytics with monsterinsights

Method #2. Add the Raw Tracking Code to Your Site’s Header With a Plugin

You can add the raw tracking code to your site’s header with the Insert Headers and Footers plugin. After installing and activating the plugin, go to Settings » Insert Headers and Footers and place the code into the plugin’s settings.

insert headers and footers

3. Manually Add Google Analytics Code in header.php

add tracking code to header.php

A slightly more complex way would be to open your theme’s header.php and place the code right after the <body> tag.

tracking code added

Please note that if you add the code to your main theme, then it will be overwritten whenever you update your theme. Using a child theme is the best way to add customizations like this to your WordPress site.

4. Manually Add Google Analytics Code in functions.php

If you feel confident in your knowledge of php you can open your theme’s functions.php and add the following code replacing the fourth line with your Google analytics code.

Code Snippet:


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

Using any of those methods you should have added Google Analytics to your site.

Please note that you might not immediately start seeing information on your Google Analytics dashboard. It will take about 12 to 24 hours or sometimes even 48 hours before you can see any data in your Analytics account.

We hope this article helped you install Google Analytics on your WordPress site. It’s a great way to optimize your website, plan your content, and grow your business.

If you liked this article, you might also read the best Analytics solution for WordPress.

Comments  Leave a Reply

  1. I use Google Analyticator. You just connect the site to your Google Account, select the Analytics Profile and it does the rest for you, including embedding a graph of your visitors into your Dashboard. Brilliant!

    https://wordpress.org/plugins/google-analyticator/

    1. Hi,

      Google Analyticator looks good. I want to try.

  2. Hey Jeremy

    Nice tutorial! You could also use Yoast’s “Google Analytics for WordPress” plugin. It supports most of GA’s features and it’s pretty easy to set up.

    – Andor Nagy

    1. Shahzad Saeed May 17, 2018 at 9:54 am

      The ‘Google Analytics for WordPress’ plugin is now rebranded as MonsterInsights.

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.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!