How to Install Google Analytics Without Plugin WordPress

In this article I’ll show you what Google analytics is, why its important and how to install google analytics easily on your WordPress site.

Google Analytics

Google analytics is a platform that helps with monitoring your WordPress site activities and, provides you with key data analysis on how your website performs. The provided data can be used to help improve your site.

Below are some of the information gathered by Google Analytics

Realtime: Displays real time data of what is happening on your site.
Audience: Shows data on who is visiting your site, plus demographics.
Acquisition: Shows how your site gets its traffic.
Behavior: Shows what site visitors do on your website, including buttons clicks as well as which of your pages are the most prominent.
Conversions: An advanced record to be utilized combined with Google Analytics Goals, to track activity such as email listing subscriptions or e-commerce sales.

Adding Google Analytics

Getting analytics code from your Google Analytics account

Login to your analytics account, then click on Admin on the left sidebar as shown below.

install google analytics admin link

On the next page, under property section click on Tracking Info then Tracking Code as shown below.

GA-tracking-code

Copy the code under Global Site Tag (gtag.js) section as shown below.

install google analytics code

Adding Code to Your Website

Login using FTP client like FileZilla

Navigate to wp-content > themes > child-theme and then download functions.php file, using an editor like notepad++, sublime text or visual studio code.

Open the functions.php file and add below code in.

<?php
add_action('wp_head', 'wpcoke_googleanalytics_code');
function wpcoke_googleanalytics_code() { ?>
 
//PASTE YOUR Google Analytics Code Above HERE
 
<?php } ?>

Save above file and upload it back to your child theme functions.php file.

NOTE: Ensure your site is using a child theme, so that any theme updates would not affect or overwrite the above code.

Leave a Comment

Your email address will not be published.