Do you want to install or implement the Google Analytics code in your WordPress website? In this article I will tell you Step-by-Step best & easiest way to install Google Analytics code on your WordPress website without using any plugins.

Google Analytics is a free tool developed & offered by Google.

Before starting the article, You need to know:

“What is Google Analytics?”

Google Analytics is Google’s free tool that provide insight of your website visitors that “how users find and use your website”, where they are coming from, track goal, conversions, eCommerce behaviour, and more activities. It is a very popular tool for website Analytic.

Google Analytics shows how much traffic is coming to your website and that traffic is coming from where. Also, how visitors behave with your site.

Why Google Analytics Tools are Important for Websites?”

After creating an informative & eCommerce websites or blogs, the most important thing for you is how people are using your site, that is, what they are seeing, where they are coming from, what content is reading more on your website, which products are selling more (Product sales behaviours).

Apart from this, it also shows the Bounce rate of your site. There is no other way to find out all these information, so Google analytic tool is used to know the site’s stats.

“How does Google Analytics tools work?”

To install Google Analytics in your site, you will need to add Google analytics tracking code to your site. When a visitor visits your site after adding the Google Analytics code, it tracks them.

Through this tracking code you can get various types of useful data:

  • Pageviews: The number of visitors to each of the pages visited on your site.
  • Traffic Source/Medium: Visitors are coming from your site (Google search, paid traffic, other website, direct, or social media network etc.)
  • Bounce Rate: How quickly visitors to your site get exit from your site.
  • Session Duration and Pages/Session: How long visitors stayed on your site and how many pages they visited during their session.
  • Goals: Through this you can find the analytics of the goal you have set for your site.

So, now let’s start the step to install Google Analytics code on your WordPress website.

Create a Gmail ID & login to your website’s admin credential to install Google Analytics. For the first time setup, you will be asked the details of your website and some personal details to start. If you are among those who already have an account.

STEP 1 (Google Analytics):

Click on the Admin tab:

Click on Create Account:

In Account setup, fill the account name related to your website such as “Avinash Singh” I mentioned for example. And then scrawl your mouse and click on next button.

Select your platform where you want to measure and then click on next:

Fill the Property details with Website Name “Avinash Singh”, website URL, select your Industry category and click on create button and proceed for Google Analytics Terms of Service Agreement.

After the selecting agreement you will get the manual script:

<!– 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’, ‘UA-166244678-1’);

So far, you have set up a Google Analytics account and created a Tracking ID for your website where you want to implement. Now the most interesting part of the tutorial starts. Let’s take a look at the next section.

There are many ways to add Google analytics tracking code to a WordPress site. But here I will tell you through header.php file method.

For this method you should have some basic knowledge of WordPress template. Follow the steps given below to add your Google Analytics tracking code in WordPress website.

STEP 2 (WordPress Dashboard):

You have to log in to your WordPress, after that in WordPress dashboard, you will get an option here AppearanceTheme Editor (Shared snapshot will help you to understand)

After clicking on the theme editor option, Select theme to edit and coding of your theme will open in front of you. Select Header.php file and place your analytics code in <head> section as much as above and after that updated the file.

<!– 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’, ‘UA-166244678-1’);


After a minutes & may be few hours, return to the Google Analytics tools from where you copied your tracking code. If you are not receiving any analytics data from the site, then click “Send test traffic” button to check it, then you will see 1 active users right now in status.

That’s it!

This way you learned how to implement Google Analytics code to your WordPress website without using any plugins. Avinash Singh makes you super simple to connect your site with Google Analytics. We hope you will understand the information given in this article very well. You may also see our guide “Step to install Google Tag Manager to website”.

Watch the full video (By AVINASH) to understand step-by-step to install Google Analytics code.

If you have any questions related to this article, then you can ask us through a comment. By sharing this article on social media, you can make your acquaintances aware of this information and help them.



Alok Prakash · 13 May 2020 at 2:12 pm

It’s a great article and informative for Digital Marketing professionals.

Renuka · 14 May 2020 at 9:40 am

Highly informative and very useful. I am going to try it. Thanks for sharing

Renaldo Summerset · 15 May 2020 at 6:42 am

Great article! Very detailed and informative!

Comments are closed.