September 13, 2019
5min Read
Domantas G.

Are you looking for a way to improve your WordPress website’s performance? Why don’t you try using Google Analytics? In this article, we’ll uncover the functionality of this tool and all the perks you can expect from using it. To top it off, we’ll also explain how to add Google Analytics to WordPress site.
Google Analytics is one of the most popular web analytics tools on the market. This Google-powered free service can give you valuable data regarding website traffic and audience behavior. Thus, you get to make data-driven decisions to plan the growth of your site far ahead.
Here are four reasons why you should consider adding Google Analytics to your WordPress site:
Before you get to add Google Analytics to WordPress site, you need to sign up for it first. Not to worry, the process is quite simple and only requires a Gmail account.
Check out the steps to signing up for Google Analytics below:

If you don’t want to tinker with your child theme, you can always use a third-party plugin to do the job. Not only is it easier, but it reduces the risk of messed up code.
Check out this article to know the steps to install a WordPress plugin.
As there are a ton of great Google Analytics plugins to choose from, we took the liberty of creating the tutorial using one of the best ones on the market — MonsterInsights.
Supporting over two million users and counting, MonsterInsights is a robust Google Analytics plugin worth considering. The plugin’s biggest advantage lies in its ability to create customized reports based on your choice of parameters.
If you only need the basic features of a web analytics tool, MonsterInsights’ free Lite version offers great choices. Should you need more options, you can upgrade to the Pro version at a starting price of $99.50 per year.
Here’s how to add Google Analytics with MonsterInsights:
When you have signed up for the service, you need to get a code snippet and place in on your website.
In order to add the analytics code to functions.php file, you need to have a child theme installed. How so? Aside from being relatively easier to modify, the child theme preserves all the changes you’ve made even when you update the parent theme.
You can check out this article to learn more about it.
After you completed the signup process, the service will redirect you to the area where you can obtain the code.
If you want to retrace the steps, here’s how to get your tracking code manually:
There are a couple of ways to add Google Analytics to WordPress with the code snippet.
The first location where you can add the tracking code is the functions.php file. You create a new function that contains the code snippet.
Note: For precautionary reasons, it’s best to create a backup copy of the file before you modify it.

add_action('wp_head','my_analytics', 20);
function my_analytics() {
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id='UA-00000000-1'"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-00000000-1');
</script>
<?php
}
You can also add the tracking code to the header.php file.

Google Analytics is a robust free web analytics tool that collects crucial information regarding your web performance and target audience. By gaining web analytics insights, you get to make data-driven decisions to grow the site in the most efficient way.
There are two ways to add Google Analytics to a WordPress site:
Knowing the vast benefits of using Google Analytics for website growth in general, we can’t wait to see you try and prove it yourself. If not now, when?
November 01, 2017
Thank you for this post, it helped me choose the best method to add Google Analytics to my website. Option 1 – Using a Plugin seems most ideal, but I am curious about the disadvantages? They contradict the advantages for theme changes and updates.
Leave a reply