How to add Google Analytics to WordPress?

Contributor, Benzinga

Data is an integral part of how we live and do business. And one great way businesses and website owners get access to important data is through Google Analytics. If Google Analytics is still new to you, this article is for you. You will learn how this great tool works, the benefits you can expect from using it, and the steps to adding Google Analytics to your WordPress site.

How Does Google Analytics Work?

Google Analytics is a powerful service offered by Google for free to help website owners track and collect helpful information about their website visitors. By helpful information, we mean insights ranging from the sources of a website’s traffic to the number of visitors per month and even user behavior while on your website.

Google Analytics puts a block of code into your WordPress website. And once installed, it collects valuable insights mainly from 3 points:

  • The HTTP request of the user: This request usually contains useful information about the browser trying to access your website.
  • Browser/system information: Google Analytics will collect information about the system it will use in creating reports.
  • 1st-party cookies: The code also will set up and read 1st-party cookies on your website visitors’ browsers to observe their session and the actions they take while on your site.

In today’s competitive market, having access to the correct information and insights will set you apart from your competition. Google Analytics is a powerful tool that businesses take advantage of to reach their ideal customers and understand what they want. It is a great way to evaluate the strength of your marketing online because the numbers do not lie. If you have not been using analytics for your website, you have been flying blind. But the good news is you can begin right now. Installing google analytics to your WordPress site is quite simple and easy to do.

Steps to add Google Analytics to WordPress

Here is a simple step-by-step guide to adding Google Analytics to your WordPress site. Following these steps will get you set up and ready to use Google’s powerful analytic tool for free.

Step 1: Sign up or in to Google Analytics

The 1st step you will need to take is to sign up or sign in if you already have an account with Google Analytics. You will be required to use a Google account to access the platform. When done, you will be asked to sign up for Google Analytics, and you will have access to several data-sharing settings and boxes you should check.

Step 2: Choose Between Web, Apps or Both 

You will be prompted to choose an option of what you want Google Analytics to track. Choosing web tells Google you want it to track analytics on your website. Next, you need to enter the website name, URL, country and time zone.

Step 3: Your Tracking Code

After accepting Google’s terms and conditions and privacy policy, the platform will give you your tracking code. This code is unique to you and your website. The code identifies your website to Google Analytics and tells it what exactly it should be tracking. You should copy out this block of code because it is essential.

Step 4: Add Google Analytics to your WordPress

These 1st steps help you get on and set up your Google Analytics account. The next step will help you install Google Analytics on your WordPress website. And for that we will show you 2 methods:

Use a Plugin

WordPress makes building and running a website easy, especially for people with little to zero experience with coding. One way it does this is by offering plugins. Plugins are kind of like ready-made functions programmed by some of the best and available for you to use.

Many plugins are available for your WordPress website, including a plugin for Google Analytics. One of the most popular plugins to use is MonsterInsights, owned by the WordPress platform and hosted as part of its premium plugins. Here are step-by-step instructions on how to add a plugin to your WordPress.

The 2nd plugin you can use is the Headers and Footers plugin. It is not as effective as some of the more standard plugins and may limit the options you can access on your WordPress Dashboard.

You will need the code you copied from the Google Analytics Dashboard and then activate the Headers and Footers plugin, adding a header and footer to your WordPress website. You will then visit the settings page and locate the header and footers page. This is where you must paste the code you copied from the Google Analytics dashboard.

Install Google Analytics in a WordPress Theme

If you are an expert with the WordPress platform, this option will be easier for you to implement. Although there are issues with using this method. For one, changing themes means you will lose the code you entered in your previous theme

There are 2 main ways to install Google Analytics in your WordPress theme:

  • Add the code to the header.php file. Edit this file and paste the code after the <body> tag and save. Afterward, upload the header.php file back to the server.
  • Add the code through the functions file. The functions file is a valuable part of your WordPress site, allowing WordPress to manage and effect changes to the functions on your WordPress site. Copying and pasting the code here makes Google analytics part of the main functions of your website.


Google Analytics is an essential tool for website owners and businesses everywhere. You will put your website and business at the forefront by using the wealth of data it offers to grow your audience, scale your brand, and hit your goals faster and more efficiently. 

Adding Google Analytics to your WordPress is not as complicated as people think. As outlined in the steps above, you can set up your Google Analytics account in minutes and start receiving insights on your website. Give your WordPress website the extra edge.