Do you know how to install Google Analytics on a WordPress site? Adding Google Analytics is the best way to track how visitors interact with a website. In this article I will show you a simple way to install GA on a WordPress site through a plugin.
Before we go to the practical part, let's take a look at what Google Analytics is, what it does and how it works. If you prefer, skip to the GA install part of the WP.
What is Google Analytics?
Google Analytics is the most popular tool and possibly the most comprehensive web analytics tool on the market. It is a free tool from Google (also available in the premium version with different features) to analyze the behavior of a website visitor.
Google Analytics allows you to collect and analyze navigation data from visitors providing valuable insights for your business and digital strategy.
With GA it is possible to measure data such as number of visitors, page views, conversions, frequency and recency, sales, campaign results, events within the site and much more.
Why use Google Analytics in WordPress?
Understanding the behavior of website visitors is critical to increasing traffic and conversions. This applies to all sites, regardless of the platform used.
With Google Analytics you have access to information about the website and visitor behavior. In this way, your decision making is guided by data and not just by your “achometer” or the stakeholders for whom you are possibly offering this service.
How does Google Analytics work?
In order to track and collect visitor data, you will need to implement a tracking code on your website. This tracking code is obtained from your Google Analytics account. If you don't have a GA account yet, I suggest reading of this Google support article.
Every time someone accesses your site, the tracking code is triggered and starts collecting data from the visitor and their session.
If you want to understand a little more about how GA collects data read this other Google support article.
Ways to implement GA in WordPress
There are several ways to implement the Google Analytics tracking code. Here are a few:
Directly in header.php
You can enter the tracking code directly through the
header.php the theme used. This is a solution that requires some technical knowledge and additional care because any hesitation in editing the
header.php can break your website. Remembering that you can also do this (insert the code in the
header.php) using a plugin.
Perhaps the least usual way to implement Google Analytics in WordPress but it is worth mentioning. As with the method of editing the
header.php this method requires editing files of the theme used or using a snippet to add the tracking code to the head of the site.
Using Google Tag Manager
This is my favorite method! Not only for the ease but also for the countless possibilities of customization that accompany it. Through this method you guarantee that your implementation will not be lost after a template update or a bad configuration / use of the analytics plugin.
Through a plugin
Possibly the most practical and recommended for beginners. Caution! There are several plugins in WP for almost any functionality. Choose a reputable and quality plugin to not compromise the performance of the site and also the implementation of Google Analytics.
Installing GA on WordPress using a plugin
As mentioned earlier, there are plugins for just about any functionality in WordPress. Installing Google Analytics is no different.
Explaining how to install Google Analytics on WordPress with each plugin would take too long. I also mentioned earlier that you should try to work with quality plugins to ensure the smooth functioning of the website.
Some people claim that the more plugins installed, the lower the site performance will be. This is only true if the quality of the installed plugins is not good. Following this line, my suggestion, among so many options available in the WordPress plugins directory, is to use the plugin MonsterInsights.
Time required for this implementation: 5 minutes.
Installing Google Analytics on WordPress using a plugin
- Installing the MonsterInsights plugin
Naturally, to install Google Analytics on WordPress via plugin we need to add a plugin. In the plugins installation area, look for “Google Analytics”, this will be enough for the desired plugin to be displayed. Install and activate:
- Start the plugin configuration
Once you activate the plugin, you can choose to start the configuration through the configuration wizard of the plugin itself or, in the main menu go to Insights> Settings (or Settings).
- Connecting with your Google Analytics account
Regardless of the configuration method you choose, you will need to connect to your Google Analytics account:
- Authenticating your account
Select the account you want to use for connection and confirm the required permissions to use the plugin:
- Selecting the Google Analytics account
Select the desired account for connection and click to complete the connection:
It is! Your website now has Google Analytics installed.
It should be noted that this plugin has several configurations that you can make good use of. Here are a few:
- Enable or disable the capture of demographic data from visitors;
- Add domains for cross-domain tracking;
- Disable tracking for some types of users (do not track activities of site administrators for example);
- Enable or disable reporting in the WordPress dashboard.
The premium version of the plugin is very robust and can save a few hours in advanced tracking implementations. Such implementations, in most cases, can be achieved through the implementation of GA via GTM.
Validating GA installation
There are a few ways for you to test whether GA is installed correctly. My recommendation is that you use an extension from Google itself for this check: the Tag Assistant.
Install the extension. Access the website and click on the extension. It will display the implemented tags:
Installing Google Analytics on WordPress using a plugin is possibly the fastest way to implement GA on a website.
The positive points of this implementation are the practicality of installation, it does not require knowledge in programming or advanced knowledge in the tools used.
Now it's up to you! What method do you use to insert GA on your WordPress site? Got some doubt or have any tips to share?
Keep reading: “What are sessions in Google Analytics?”