How To Add Google Analytics to WordPress

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on whatsapp
Share on email

Adding Google Analytics to the site is essential as it will help you to take important decisions for your business.

Why you need Google Analytics? It allows you to track and understand your user behaviour and activity on your site. 

3 Ways Through which you can add Google Analytics to WordPress:

  1. Using WordPress Plugin for Google Analytics
  2. They are directly Injecting the code to the theme.
  3. Adding Google Analytics into Google Tag Manager

We will be discussing all the ways how to do it, in a simple way.

Using WordPress Plugin for Google Analytics

  1. Go to the plugin section and search for GA Google Analytics By Jeff Starr.
  2. After Installing the Plugin go to the Plugin Setting.
  3. You have to enter the GA analytics ID in the Setting Page.
  4. You have successfully added Google Analytics to the website.
How To Add Google Analytics to WordPress 1

Directly Injecting the code to the theme

  1. Go to the Appearance then theme editor.
  2. From the left panel, you have to select the header.php file.
  3. Copy and paste this code just after <HEAD> tag
  4. Then Press the Update Button to Save the Theme.
How To Add Google Analytics to WordPress 2

Adding Google Analytics into Google Tag Manager

If you haven’t used Google Tag Manager, then you don’t have to worry about this.

1. I will be explaining to you all the steps. Go to the GoogleTagManager, then press to create an account.

2. Then Fill the Details, ie. Account Name, Country, site URL and Target Platform.

How To Add Google Analytics to WordPress 3
How To Add Google Analytics to WordPress 4
Code of GTM which you have to copy

3. The next step is a bit complicated, but not that difficult. Just follow the steps with me.

4. Go to the Appearance > Theme Editor > Header.PHP, you have to copy the GTM code into the header file.

There are 2 sections, Section 1 you have to paste in HEAD (Highlighted with Pink Color), Section 2 you have pasted in BODY (Highlighted with Red Color

How To Add Google Analytics to WordPress 5

5. Press the update button to save the file.

You have completed all the steps. You can track user activity in Google Analytics in Real-Time Tab.

More To Explore

Subscribe To Our Newsletter

Get updates and learn from the best

Contact us