How To Add Google Analytics To WordPress [With & Without Plugin]

how-to-add-google-analytics-to-wordpress-website-without-or-with-plugin-themaverickspirit Pin It

Looking for a way to add Google Analytics in WordPress website? 

It’s essential to understand how your website visitors are interacting with your website and which posts and pages are performing well. 

You can do so by keeping track of traffic stats on your website by adding Google Analytics tracking code.

Well, today, in this post, you will learn how to install Google Analytics in WordPress? With and Without a Plugin [Step-by-Step] 

But before moving directly to the installation of Google Analytics, let’s first understand what Google Analytics is and what are its benefits. 

What is Google Analytics?

Google Analytics is a free web analytics tool developed by Google back in 2005. It is used to track and report the website’s traffic. 

The benefits of Google Analytics include a better understanding of – 

1. Type of Traffic (or Traffic Channel)

With the help of traffic channels, you can understand how your website visitors are finding your website. 

Major traffic types include direct traffic, referral traffic, organic traffic, social traffic, etc. 

2. Social Platforms

You must understand which social media platform is bringing maximum and minimum traffic. 

You can prepare strategies for social media that bring a minimum or less amount of traffic. 

3. Amount of traffic

Google Analytics helps you to track and report the amount of traffic you are getting on your website. 

You can check which page or post on your website is working well and which is not. 

It also lets you compare traffic with the previous month’s traffic so that you can calculate the website progress.  

4. User’s Behaviour

You can check the pages a user is landing, how many pages he has visited in that session, and what amount of time he/she spent.

You can use these detailed insights to optimize your website for more traffic and conversions. 

Now that know what Google Analytics is, let’s understand how to add Google Analytics on WordPress website. 

Google Analytics Integration in WordPress

Google Analytics integration in a WordPress website is super-easy and doesn’t require much technical knowledge and can be done even by WordPress beginners. 

The installation process of Google Analytics is divided into 3 steps – 

  1. Create a Google Analytics Account
  2. Add Google Analytics code to WordPress
  3. Test Google Analytics Tracking Code

We will go through each of them step-by-step. 

First and the last step is always going to be same regardless of the installation method. 

How to Signup with Google Analytics?

The minimum requirement to create a Google Analytics account is to have a Google account.

Recommended – If you are setting up Google Account for your business or blogging website! I recommend you to opt for G Suite to keep everything professional.

So if you don’t have one, first create a Google account to get started with Google Analytics. Let’s check out the signup process. 

Step 1: Visit Google Analytics sign up page. 


You need to log in with your Google account. 

Step 2: Post login, you will be redirected to the Google Analytics welcome screen, where you will find a “Set up for free” button. 


Step 3: You will be asked to fill out the Google Analytics account details, including account name and data sharing settings. 


You can use any name that represents your business or website. 

Step 4:  Next, you need to select the device type on you want to set up your analytics account.

Select “Web” for your website and Apps for the android app or iOS app.  


There’s also a third option of selecting both web and apps, but it’s still in the beta version.  

Step 5: Lastly, you need to enter the property details, including website name, URL, the industry that your website belongs to, and timezone. 


Step 6: It will redirect you to the Google Analytics dashboard, where you will find the Google Analytics tracking code. 


This tracking code will be used when you install Google analytics with the WordPress plugin. 

On the other hand, if you choose to install Google Analytics manually, you need to copy the javascript code.

How to Add Google Analytics to WordPress Website Using Plugin?

I am going to share five methods with which you can set up Google Analytics tracking code in WordPress with the help of plugins. 

I am listing out three methods where you need to install a WordPress plugin to add Google Analytics tracking code to your WordPress website. 

So, let’s check them out. 

Method #1 – Using Google Analytics for WordPress by MonsterInsights

MonsterInsights is amongst the best Google Analytics WordPress plugins that allow you to install Google analytics code easily without having any coding knowledge. 

Recommended – You can read the complete process of connecting Google Analytics with MonsterInsights in MonsterInsights Review post.

Method #2 – Using GA Google Analytics Plugin

GA Google Analytics is another plugin with which you can easily add Google Analytics tracking code to your WordPress website. 

Just like MonsterInsights, you need to install and activate GA Google Analytics plugin.  


After installation, you need to add Google Analytics tracking ID to the plugin settings. 

For that, Go to Dashboard > Settings > Google Analytics > Plugin Settings.


Add the tracking ID we copied in step #6 of the above section and paste it in the GA Tracking ID field. 

Make sure you select – 

  1. “Universal Analytics / analytics.js” in the tracking method, and 
  2. “Include tracking code in page head (via wp_head)” in the code location. 

Method #3 – Add Google Analytics Code via Insert Headers & Footers Plugin

First, you need to install and activate the insert headers and footers plugin. 


Upon plugin activation, Go to Dashboard > Settings > Insert Headers and Footers.


You need to paste the Google Analytics JavaScript code (obtained in step #6) in the Scripts in Header field. Save the settings. 

How to Add Google Analytics to WordPress Blog Without Plugin?

Method #1 – Add Google Analytics Code via Functions.php File 

Another method of adding Google Analytics code is to add code to functions.php


You need to insert the following code to your theme’s functions.php file. Make sure you replace the “TRACKING-ID” (2 instances) string with your Google Analytics Tracking ID.

function maverick_google_analytics() { ?>

// Paste Google Analytics JavaScript code from Step #6
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'TRACKING-ID');

<?php } 
add_action('wp_head', 'maverick_google_analytics');

Method #2 – Insert Google Analytics Code Into Header.php File

If you don’t want to use a WordPress plugin, then you can directly add the JavaScript code to the header.php file of your WordPress theme. 

Go to Dashboard > Appearance > Editor. 

Once the editor opens, you need to click on header.php to open it into the editor. 

Paste the JavaScript code just before the closing </head> tag. 


Save the file and you are done. 

How to Check if Google Analytics is Working?

The final step is to verify if Google Analytics is installed correctly and works well on your WordPress website. 

You can check it yourself just by following the below steps – 

  1. Open your website in the new tab. 
  2. Open the Google Analytics Dashboard and Go to Real-time. 
  3. If Google Analytics is connected properly to your WordPress website, it will display the number of real-time active users along with the device type. 

Google Analytics FAQs

1. Is Google Analytics free to use?

Yes. Google Analytics is free to use. Google has also introduced an advanced paid version of GA named Google Analytics 360.

2. What is the use of Google Analytics?

Google Analytics is used to track traffic metrics, including the source of traffic, stay time, bounce rate, average session, and much more.

3. Where do I put the Google Analytics code?

It is recommended to add Google Analytics tracking code to the <head> tag of the WordPress website.

4. How to check google analytics on WordPress Dashboard?

You can check google analytics data on your WordPress dashboard by installing MonsterInsights WordPress Plugin.

Which Method Should You Choose to Add Google Analytics to Your WordPress Website? 

Google Analytics is a powerful tool that plays a crucial role in the improvement of your WordPress website. 

It allows you to track and analyse how well your content is performing and help you to strategise and improve your content accordingly. 

Talking about which method should you choose, as a beginner you can go with MonsterInsights or GA Google Analytics.

If you are familiar with code a WordPress expert, you can go with any of the above methods, including functions.php or header.php

In case, if you have any issues while adding the code to your WordPress website, you can comment them below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link