How to install Google Analytics on WordPress easily, le 03/05/2021

News

How to install Google Analytics on WordPress easily

If you want to have a successful website, you need to know your visitors. Know them and then know what content they want. Then bring it even more to your site. The best way to do this is to analyze your traffic. This is exactly what Google Analytics does. This free software from Google allows you to track visitors to your website, analyze their habits, traffic sources, social statistics, and many other statistics. By analyzing the statistics, you can plan and create better content for your readers. This tutorial will show you how to register and add Google Analytics to your WordPress site.

Why do you need Google Analytics in your WordPress?

Things are pretty easy when you know what your users want from you, your website, and your services, right? The only way to get your visitors addicted to your website is to provide them with what they naturally need. This is exactly what Google Analytics does and for free on top of that! Here are some reasons why we suggest adding Google Analytics to WordPress and thinking that every WordPress blog should have it:

  1. It helps you determine the behavior of your users. Yes, you can closely monitor the behavior of your visitors with Google Analytics. You can easily check the most visited pages, the average time spent by each user on a certain page, the best-performing pages, as well as detect the page that drives your visitors to leave your website and much more. Having access to such information would help you better optimize your website. If a blog post is what brings you the most views, you can write more posts on related topics and attract more similar traffic.
  2. It helps you to analyze the most active schedule of the day. You can easily determine the time of day when you get the most traffic. If most of the users are active at night, it is obvious that to have a maximum return, you should schedule your posts for late hours.
  3. It helps you to know crucial details. Google Analytics can provide every detail - from the geographic location of any user to the language they speak, the browser they use, the screen resolution, and tastes. Thus, it helps you to better understand your audience.

While there are several other web analytics services you can use, Google Analytics offers a range of exclusive features. Let's take a look at each of them:

  1. Generate custom reports easily. The best way to analyze the behavior of your users is to use statistics. This can be easily done by generating custom reports through an easy to understand interface. You can add various parameters and metrics to generate a pragmatic report.
  2. Configure custom alerts. This is an awesome part of Google Analytics with which you can send a personalized alert in the form of a text message or email whenever there is a sudden spike in traffic or a drastic change in the bounce rate. So you don't have to keep your eyes glued to your dashboard any longer to access important updates.
  3. Integrate Search Console. Keeping an eye on SEO statistics is important. The Search Console is a tool that allows you to do this and will provide you with information related to search engine optimization. Integrating Search Console with Google Analytics will make information easily accessible in one place for quick analysis.

These are just some of the many features of Google Analytics that make the whole process of managing a WordPress site easy and efficient!

Step 1 - Create a Google Analytics account

The first thing you need to do is to create a Google Analytics account and get the tracking code, then follow these steps below on how to sign up for Google Analytics:

  1. Start by navigating to the Google Analytics home page. Press the Connection button at the top of the page, then select Google Analytics.
  2. You will be redirected to the login page. Enter your Google email address and tap the Next button. If you don't have a Google account yet, create one by pressing the Create Account button.
  3. On the next page, enter your password and press the Connect button.

Step 2 - Adding Google Analytics to a WordPress Blog

There are plenty of ways to add the Google Analytics tracking code to WordPress: using a plugin, adding a tracking script directly to the header.php file, or creating a new function in the functions.php file.

Solution 1 Using a plugin

If you are not familiar with the WordPress and PHP file structure, it is recommended to use the plugin method. One of the best plugins for this is Google Analytics. This plugin will insert the Universal Analytics tracking code automatically - just enter your tracking ID.

The steps below show how to install the plug-in and insert the Google Analytics tracking ID:

  1. Log in to the WordPress Dashboard and install the Google Analytics plugin
  2. Once the installation is complete, go to the Settings section and tap Google Analytics Code.
  3. Paste your code in the field and click Save.
  4. That's it, the tracking code has been successfully added to your WordPress blog.

Please note that Google Analytics may take between 12 and 24 hours to update and start to display the first results. Next, audience statistics will be provided in the Reports tab of Google Analytics.

Solution 2 Inserting the code in header.php

As we told you, there are many ways to integrate Google Analytics code into a WordPress blog. For example, the code can be included in your theme's header.php file:

  1. Go to the WordPress administration area and go to Appearance -> Editor
  2. Open header.php for editing.
  3. Insert the Analytics tracking code you acquired in step 1 before the </head> tag and press the Update File button.

Note: the Analytics code will only be inserted on your active theme. You will need to add it again if you change the theme.

Solution 3 Create a new function in the functions.php file

This method requires some basic coding knowledge and we recommend that you follow it only if you are confident about what you are doing. Besides, it is strongly recommended to create a backup of the functions.php file or even of the entire WordPress installation before continuing:

  1. In the WordPress dashboard, go to the Appearance -> Editor section
  2. Select functions.php from the list of files on the right
  3. The following code snippet creates a new function and inserts the Analytics tracking code just before the </head> tag on your WordPress site. Paste this code at the bottom of the functions.php file, but be sure to change your tracking ID.
  4. Save the changes you made by clicking the Update file button.

Conclusion

Google Analytics is essential for the success of your WordPress site. You will better understand your audience and therefore provide them with much better content in their eyes. At the end of this tutorial, you learned how to create a Google Analytics account and three different ways to add Google Analytics to your WordPress blog.