How to Add Google Analytics to WordPress

How to add Google Analytics to WordPress? What is Google Analytics? Find out the answers to these questions and much more in today's article.

Updated: 14 Dec, 21 by Antoniy Yushkevych 14 Min

List of content you will read in this article:

Google Analytics plays a pivotal role in your journey of running a website. This incredible tool helps you to understand the insights of the site. How? Let us give you a detailed analysis of the topic.

We have bifurcated the article into several segments for a better understanding. Take a look at the below-mentioned pointers.

  • What is Google Analytics and why do you require it?
  • How does Google Analytics work?
  • Method to sign up with Google Analytics
  • Add Google Analytics to WordPress with the help of a Plugin
  • Add Google Analytics to WordPress without the help of a Plugin

Now that you are familiar with the sub-topics, let us tread ahead.


If you are a tech newbie, you may not be acquainted with this terminology. Well, we are here to simplify the term for you.

Google Analytics is a tool designed to analyze and understand website traffic. Web traffic is simply the number of users who visit your website.  Basically, this tool permits the Google search engine to keep a check on the activities of the visitors on your website. This information holds great importance for analyzing several aspects of the tracked data. This data helps you to improvise your strategies to attract a greater number of people to your site. 

Additionally, here is a list of some tips and suggestions as to what you can do after receiving the analytics. 

  • Your visitors: It helps you to attain geographical information about your visitors. This further assists you to understand the location of your audience!
  • Focus area of the visitors: There are many pages of a website. It helps you to track where the visitor drops off from a particular page. Additionally, it also helps you to know for how long the visitor stays on a page. These factors are extremely helpful for you to make significant improvements in your content and data. 
  • How did they find you: GA software tells you how the audience finds you. Whether through search engines, links on some websites, social networking sites. Or by straightaway entering your website’s address.
  • Helps to know the conversion rate: Conversion rate means how many visitors are not just visiting your website but fulfilling your desired goals. Your goals can be, buying some packages or subscribing to your content, etc. It also informs you about the links they accessed on your website. 

Once you have tracked the data, what to do next? 


Now, the next question is how to utilize this information in better optimization of your website.  Once Google Analytics has shown you the data reflecting different aspects of the analysis, you can make changes in the following segments.

You can improvise the content by publishing more data that the visitors are interested in. Work on filtering out which data the visitors are looking for and hence, deliver the most in-demand content. Moreover, do keep a check on when the visitors are most active. That will help to escalate the reach of your website. Additionally, you can track the marketing campaigns to check whether your inputs are affecting the product sales or conversions effectively or not. 

After you track your conversion rates, you must analyze which pages present on your website are performing the worst. Work hard on such pages and deliver better content. 

The improvisations have a good probability to bring more traffic to your website, which is the ultimate objective of every business. Keep experimenting by adding more and more features to your site to attract the audience. For instance, you can add multilingual features that will prove to be beneficial for you to attract an audience from a much wider geographical location. Or you can add relevant videos or images related to the product that are appealing and informative.

Keep hunting for fresh ways and methods to attain more traffic to your website. Therefore, Google Analytics helps you to make decisions by analyzing accurate facts and data. Now, let us move towards our next segment.


Here is a detailed explanation of the working of Google analytics in a step-by-step fashion.

For starters tap on the home button. The main page appears in front of the screen as shown in the snapshot below.

Clearly, there are two partitions on the screen. On the left-hand side, you can see three options, namely, Life cycle, User, and Events. 

Take a look at the right side, this is the section where the statistics of your website are visible once you choose which data to analyze from the left. 

Some of the most essential factors are inhibited in the life cycle segment. Following this, is a brief explanation of each one of them. 

Acquisition: This segment tells you about the total number of users along with the new visitors that visit your website. It also showcases the time when the user visits. Additionally, you get aware of the source which redirected the users to your website. Whether a search engine, social media, or some other source. 

Engagement: The engagement section tells you about all the activities that a particular user does on your site. Complete detail about the total time spent on the pages, which pages they visited, or when did they leave a particular page is shown. 

Monetization: This section tells you about your revenue, in case you sell products through your website or run various advertisements. You receive information about the products that the visitors buy or the ads they click on and the data about several other financial aspects.

Retention: there are different kinds of users who visit your site. Retention helps you to understand the engagement and the value of your users. This way you can strategize your content according to the main intent of the audience.

Demographics: demographics in Google Analytics help you to know about the gender, language, interests of your audience.

Tech: To your surprise, this software also passes you the information about the device, browser, screen resolution, or the operating system that the user is accessing.

Conversions: conversions play a major role in evaluating the performance of your website. It tells you whether you are accomplishing your goals or not. You must keep a regular check on this section.

Analysis: Your data is represented in the form of several graphs.

These were the provisions by the Google Analytics software to assist you in enhancing and analyzing the web traffic for your website. Let us now explain to you, the method to Sign up with Google analytics on your WordPress by using a plug-in.


The initial step is to create a Google Analytics account.

  1. Head towards the Google Analytics homepage and click on create account option as shown in the snapshot below.

If you already have an account then you are good to go, but if not, here is the process of creating one.

Select the Set up for free button as shown below.

After that, create an account. Enter your name in the textbooks given below the Account name option. Click on the following checkboxes under the Account data sharing settings.

Here, it’s your decision if you want to enable or disable the options. Besides, you may want the first option as it helps you to use the enhanced demographics and interests report.

Click on Next. You see a Property setup window on the screen.

Now, what does property mean here? This section asks for the website or any app that you wish to track by Google analytics. 

You also have the option to run several websites or applications under this account at the same time. If you wish to upload a plug-in to your WordPress site, you have to create a property by using an older version of Google Analytics, known as Universal Analytics. 

To accomplish this, select Show advanced options. This opens a window where you can easily create a property. 

After clicking the appropriate option, hit next.

Now, select the appropriate checkboxes according to you. Google analytics basically asks for information about the website. You can skip this window if you want to!

Click create. The next step displays the terms and services page. Accept the norms and conditions and move ahead.

Moving ahead, the next task is to set up the data stream. The main objective of the data stream is that you can track the sources of data. There are three options available, namely, Android, iOS, or web property. 

As you are looking forward to adding Google Analytics to your WordPress website, tap on the Web option as shown in the below snapshot.

You have to pass through some additional steps. Define the website address as well as the stream name in the respective text boxes. Take a look at the snapshot.

The next window showcases the kind of data you want to collect through Google analytics. There are several options, for instance, scrolls, page views, outbound clicks, video engagement, site search, and file downloads. Enable all the options as per your needs. 

Here is a snapshot of the window that displays on the screen.

After making the appropriate selection, click on Create stream. You also have the option to make desired changes whenever you want. 

The last and final step is to find the tracking code as well as the measurement ID.

Go to the Web stream details as shown below.

Let us now move towards installing the plug-in.


There are a plethora of choices for the plug-ins in order to connect with Google analytics. Our choices Google site kit. Google site kit is officially a Google plug-in that helps you to connect the site with Google analytics in some simple steps. There are other Google services like PageSpeed insights, Search console, and AdSense. This plug-in helps to display the important data and information on the WordPress dashboard.

The first and foremost task is to install the plug-in. Navigate to Plugins and then Add new. Enter the name of the plug-in in the search box as shown.

Hit on Install Now and then press Activate.

As soon as the activation is done, a message pops up that contains the Start setup button.

Hit on this blue button. The verification of the site begins, and you see the following page. 

Click on the Sign in with Google button. Now, enter into your Google account by filling in the credentials and hit Next.

Accept a bunch of permissions that Google asks and move ahead.

The next page will ask for the verification of site ownership, access to the Google account data, and addition of your site to the search console. 

Keep clicking next and you are done. The last window showcases the Go to my dashboard button. Tap on it and that is it!

Moving on, go to the Site kit and then click on Settings. Lastly, hit Connect more services options as shown below. 

Now tap on Set up analytics, enter the mentioned details and click on Configure analytics

Congratulations! Your WordPress is successfully connected with Google Analytics now. After building a connection between WordPress and Google Analytics, you can easily analyze the information displayed on your WordPress dashboard. 

To view the data, go on the Site kit option available on your dashboard as shown. 

As you can see, you can easily alter the time duration of the data you want to view. 

Moreover, if you wish to change the settings of Google analytics, navigate through Site kit, Settings, and then Connected services

Make the desired changes and then hit on the Edit link to change the settings. 

That’s it, explore the tool and gain benefits in the long run. Treading ahead, you can install Google Analytics without a plug-in too! Take a look.


If you’re not using a plug-in, then you have to add a code to track the visitors on every page of the website. Let us understand how to do it.

The first method is to insert the code into the header. The header remains constantly visible and appears on every page that you open. This way the tracking code automatically sets on every page.

Most of the themes have a header.php file for the header section. You can insert your tracking code here.

To perform any changes, we recommend doing it in a child theme. Go to the Appearance option present on the dashboard and copy the code from header.php file from the main theme. 

Now, paste the code into header.php after the <head> tag. Contain the overall code in <script> tag.

Click Save. And you’re done.


The second method is by using functions.php .

Go to the functions.php file of the child theme and add the code given below. 

function ns_google_analytics() { ?>

            <script async src="***********"></script>


                          window.dataLayer = window.dataLayer || [];

                          function gtag(){dataLayer.push(arguments);}

                          gtag('js', new Date());

                          gtag('config', 'G-B175YGY1T1');




add_action( 'wp_head', 'ns_google_analytics', 10 );

Save the code and that’s it! You have installed Google Analytics on WordPress without using a plugin!


Google Analytics is a strong and powerful tool to track and analyze the information received at your end. The website’s health can increase manifold once you understand the basics of it. 

We hope that this article helps you to understand the dynamics of Google Analytics and the installation process.

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at