How to Setup Google Analytics on a WordPress Website

  • 6 min read


If you have a website but you don’t have Google Analytics installed, or you don’t know how to do it, read this post. I’ll explain what Google Analytics is, how to install it on a WordPress website and what benefits you can get from doing so. Let’s start by taking a look at what Google Analytics is.

Google Analytics is a free web analytics service that tracks and reports website traffic.

You can use Google Analytics (GA) to answer questions like.
  • How many visitors come to your website?
  • How long do they stay?
  • What pages do they visit?
  • Where do your visitors live, how old are they, etc.?
  • What websites send traffic to your website?
  • How many visitors have you converted to leads?
…and much more.

In short, GA can give you a complete overview of your website’s traffic and performance and help you achieve business goals.

Everyone from individual bloggers to big corporations uses some web analytic solutions, and Google Analytics is one of the best ones (and it’s free, which is always a plus).

Every website has some goals the owner wants to achieve.

For a personal blogger, that may be the desire to share knowledge and connect with like-minded individuals. For a business, it may be to drive traffic and generate leads. Whatever your goal is, you need to understand your visitors so you can serve their needs better. Without this information, you have no way of knowing how close you’re to achieving your goals.

How does Google Analytics work?

GA tracks visitors to your website by storing and retrieving data through browser cookies.

You first need to add a snippet of code to your website so it can gather data on how your website is performing.

Whenever someone lands on your website, they are tagged by the tracking code, and their “session” begins. As long as they’re on your website, their data will be collected and available for you to look over.

You’ll be able to tell you:
  • how they found your website,
  • how long they stayed,
  • what content they read and so on.
The tracking code should be placed on every page of your website if you want to track everything accurately. This will make sure that every visitor is adequately tracked as he moves from one page to another.

Data collected by GA tracking code includes essential metrics, such as:
  • Page views: total number of times your website’s pages are viewed.
  • Sessions: the number of individual visitors your websites receives
  • Traffic source: where your visitors come from (Google search, social networks, etc.)
  • Bounce rate: the percentage of the visitor who came to one page and left immediately
  • Session duration: how long the visitor has stayed on your website
There are many more metrics to analyze; all of them really useful for any website owner.

Google Analytics goals

One of Google Analytic’s primary functions is creating goals. Goals are events that your website visitors may complete and are then trackable by GA.

You can track things like:
  • visits to specific webpages,
  • submitted contact forms,
  • purchases on the website.
It is advisable that you set up at least one goal, or even more if you want to track how good your website is performing in multiple segments.

For example, if you have a webshop, you may want to track how many users reached the checkout page, how many completed the purchase and how many contacted you.

Following goals results will show you which users are converting more, depending on their web source, or country or any demographic indicator.

This will help you determine how to optimize your website for the best conversion rate results toward those users.

To set up a Google analytic goal go to Admin>Goals. Once your goals are set up, go to Goals>Overview to track them.

Goals will also help you with tracking key performance indicators (KPI). Some of the KPI-s are already tracked by Google analytics by default, and others should be defined manually as goals.

Some of the most common KPI-s are:
  • Number of unique visitors on a website
  • Number of sessions
  • Number of generated leads
  • Number of generated sales
The desired KPI-s should be determined before any web marketing activities and should be compared with accomplished stats in Google Analytics on intervals.

How to install Google Analytics on your WordPress site?

First, you need a Google Analytics account. If you already have a Google account, use it to log in Analytics (link). If you don’t have a Google account, go ahead and create one.

When you click on sign in to Analytics and select an account to use, you will be taken to a three-step process to create your Analytics account.

google analytics wordpress

After you click Sign Up, you will have to fill out some basic info about your website. The important thing here is to set up your properties. A “property” is your website or mobile app.

You can have up to 50 properties under one Google Analytics account. For the sake of this guide, we’ll assume you only have one website and one feature.

Once you have set up everything, it’s time to install the GA code on your website. Click on “Get tracking code” button, and you’ll be taken to a page with your tracking code and instructions on how to install it.

google analytics wordpress

This is the Javascript code snippet you’ll have to copy on your website.

There are several ways you can do this, but I recommend choosing between these two:
  • install the code manually
  • use a WordPress plugin to install the code
Let’s take a look at both options.

Install the code manually

To do this, log in your WordPress dashboard and click on the Appearance>>Editor. In the Theme editor, look for header.php on the right side of the screen.

add google analytics tracking code

Click on that, and you’ll see a block of code (that’s your website’s header). Find the part of the code that looks like this: <body> and paste the code behind it (anywhere before the </body> tag).

This will make sure the GA tracking code is installed in your website’s header. And since your header is a part of every page on your website, this means that the code is applied to the whole website.

Click on the Update button and leave WP dashboard. To check if the tracking code is working, go to Analytics dashboard and click on “Check tracking code status.” You will receive a notification if everything is set up correctly.

Use a WordPress plugin to install the code

If you don’t want to install the code manually, you can always use a third-party WordPress plugin to add it to your website.

There are many plugins you can use, but not all of them are entirely reliable. However, a great plugin that can make your life easier is Google Analytics by MonsterInsights.

This plugin allows you to install the code easily through its interface. First, install the plugin by downloading it from the link above, and upload it to your WordPress site through Add new plugin>>Upload.

Or, go to the same place, search for the plugin and click install. When it installs, set it up by following the instructions. You’ll have to go to the Settings page and authenticate your Analytics account.

After you click this, log in with your Google account and copy the code you receive in the field in the plugin settings page. That’s it; you have Google Analytics installed on your WordPress site.

Wrapping things up

I have shown you what information about your website you can get by using Google Analytics, and how you can benefit from it.

The information you get from GA can be crucial when you’re trying to see how many of your website’s goals have been achieved. Google Analytics is the most powerful free analytics solution available. It’s easy to set up and use, and I recommend it to everyone who has a website.

If you have any questions about how to set up Google Analytics on your WordPress website, or you need help with analyzing your website’s performance, please contact us today, and we’ll help.

Contact us

  • This field is for validation purposes and should be left unchanged.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:


Subscribe to our newsletter