How to Install and Use Google Analytics in WordPress

Google Analytics is a powerful modern tool to improve the performance of your WordPress site on the basis of studies of its audience. Google Analytics provides virtually any information about user behavior on your site or blog. But you should first of all bear in mind that Google Analytics will not work with sites that are hosted on a free WordPress platform. So if you want your project to develop and instantly improve, the first step in this direction would be the purchase of a good hosting service.

In this article, we will examine a consistent guide to install the Google Analytics tracking code on your WordPress site, as well as the basic techniques of audience research with the help of this wonderful tool. This information will be helpful for novice administrators of the sites in WordPress platform. We recommend using Google Analytics with the earliest days of your site launch. This allows you not to miss out on any changes in the composition of the visitors and their behavior on different pages of your project.

The main advantage of using Google Analytics is its simplicity and user-friendliness due to an intuitive interface. You will see that the Google Analytics installation and usage is pretty easy as we move on to our guide.

Getting Google Analytics Tracking Code

Tracking CodeThe obvious fact is that you need a Google Account to use the Google Analytics service. If you do not have an account yet, it is very simple to create it through the registration page. After that you can take advantage of many other services, along with Google Analytics.

During the first visit to your Gmail account, you will be prompted to use the Google Analytics service. If you already have an account, or for any reason you do not receive an automatic bid, you can nevertheless go to Google Analytics home page service.

Next you will need to choose the type of account between Universal and Classic. We recommend that you select Universal type, which is a newest elaboration from Google. Also, make sure that you create an account for the web site, not for the mobile app. After this you will be given the opportunity to fill in data about your account. There is a few simple fields, in which you should enter the account name, URL of your WordPress site, select a thematic category and set the time zone for correct data display.

Once you fill out a simple application form, click on Get Tracking ID button. You will get the ready Google Analytics tracking code to be used on the site. We will analyze exactly how to use the tracking code in detail in the next section of this guide.

Installing Google Analytics in WordPress

There are only 3 ways to implement Google Analytics tracking code to your WordPress website or blog. You can use special plugins, manually edit the header.php file of your WordPress theme or make changes in function.php file. We have brought these methods in ascending order of difficulty, so beginners will be the most preferred to use plugins.

The amount of plugins to install tracking codes and other custom elements is very wide. But for novice administrators it is better to adhere the principle of maximum simplicity and the use of the free and easy-to-install plugin Insert Header and Footer. With it you can easily add Google Analytics code without risk to break the functionality of the site.

A further method involves editing the header.php file of your WordPress theme. This means that you should have at least a minimum understanding of the code of this file to find the body tag and paste the tracking code right after it. If you have already managed to close the page with Google Analytics, you should not worry. You can always find your Google Analytics tracking code in your account settings.

The last method offers the editing of function.php core file. Be careful with this file and edit it only if you understand its contents. To implement tracking code you should insert the following code into function.php file:

add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Paste your Google Analytics code here
<?php } ?>

Do not forget to save the results and replace the appropriate file (header.php or function.php) through your site`s FTP.

Note that Google Analytics work results will be available to you in 12-24 hours after the start of the tracking code on your WordPress website or blog.

Analyzing User Activity on Your Site

So, you are longing to find interesting data about user behavior on your site. First of all it should be understood that the completeness and value of analysts will depend on the sample size for your site. In other words, if your site is visited only by a few people, then the data can not be considered reliable. It is necessary to attract visitors from social networks, use contextual advertising from Google Adsense or via an internal website optimization for its appearance in search results on the core needs of users.

If you are working on the site content and its distribution, users will sooner or later appear. At this point you will need Google Analytics, which is already pre-installed on the pages of your WordPress website or blog. You will be able to analyze the set of behavioral indicators of your site audience. Let us stop our attention on the most interesting moments of these metrics.

Audience Overview

Audience OverviewThis tab contains all the general information about attendance of your site users – from the number of visitors per day prior to their geographical location. Overview tab provides a summary report of all the data on your audience. In the subcategories you will find more detailed information on the number of active users, sources of traffic by geography, gender and age of users and a lot of other useful information. Do not forget to set your desired time interval in the upper right corner (the last week data will be shown by default).

Acquisition Overview

Acquisition OverviewThis section provides detailed information about the sources of traffic for your website. Here you will find reports on the number of users involved using Google AdSense, social networking and other campaigns created to increase the audience of the site. You can set specific goals for different types of traffic, and then monitor the level of implementation of one or more strategies.

Information from the data section will be useful to focus on the sources of traffic, bringing the largest number of users for the site. You can also find out the weaknesses of your WordPress website or blog and take a number of actions to improve them.


BehaviourBehavioral metrics have a huge impact on every site or blog. The most important indicators of user behavior on the site are the duration of the visit, the depth of browsing and bounce rate. Based on these data, you can weed out the junky traffic, which does not bring any benefit to your project. After dropping it out you get more objective information on the number of interested visitors and their behavior on the website.

Behavioral metrics will also help to determine the pages on the site, which are often visited by your users. Based on this analysis, you can determine the types of content that are most popular among your audience, and to devote more time to them.


These category is relevant only for online shops. WordPress offers a lot of opportunities to create and maintain online stores. However, this section of analytics is of value only for certain types of projects, so we will not discuss it in detail.

Final Words

Feel free to use all features of Google Analytics for the best performance of your WordPress site ot blog. Over time, you will be able to use more possibilities inherent in Google Analytics. Not all features are the important tools in the first days of use, therefore there is no need to study it immediately and fully.

And we will continue to guide you through the difficult path of knowledge of all the pitfalls of the WordPress administration!

Disclosure: This page may contain external affiliate links that may result in us receiving a comission if you choose to purchase said product. The opinions on this page are our own. We do not receive payment for positive reviews.
0 replies

Leave a Reply

Want to join the discussion? Feel free to contribute!

Leave a Reply