You just got your new WordPress website up and running? Great. Now, do you know whats the most important thing you should do first? It would be best if you considered implementing a visitor tracking code to measure the traffic or number of visits your site gets.

Google Analytics is one of the most popular visitor tracking code. It also helps in providing a lot more information on website visitors and widely used.

How to install Google Analytics using Google SiteKit

Google SiteKit is one of the easiest ways to integrate your website with many essential Google services to your site without the hassle of copy-pasting any code. Google sitekit was released in October 2019 by an announcement at Official Google webmaster central blog. I think Google should have done this way back, But better late than never. You can use Sitekit to integrate your website with the following services: Google Analytics, Google Search Console, Google Adsense, Google Tag Manager, Google Optimize, and Google Page Speed Insights. You can connect with all the services mentioned above very quickly. 

How to install Google Analytics with a plugin

WordPress plugin repository has many plugins to help you implement google analytics. Here are a few free plugins that you can install on your website.

GA Google Analytics
I found, GA Google Analytics plugin to be one of the quick & lighter plugins to install google analytics tracking code on your website. They also have a pro version of the plugin with enhanced features.

Google Analytics Dashboard Plugin for WordPress by MonsterInsights
This plugin is the most popular WordPress plugin for Google Analytics implementation, and it has tons of features. They also have a paid version of the plugin with extra features for eCommerce tracking and many more.

WooCommerce Google Analytics Integration
If you run an eCommerce website based on the Woocommerce plugin, then you should use the “WooCommerce Google Analytics Integration” plugin in addition to any of the above two plugins. WooCommerce Google Analytics Integration plugin will enable you to track add to cart, checkout, and many other woocommerce events in google analytics.

How to install Google Analytics without a plugin

If you are a brave DIY person or know basic HTML and PHP, You can try installing google analytics without a plugin.

The simplest way to set up google analytics on your website is to copy the tracking code from your google analytics account and paste it in your current active theme’s header.php file before </head> .

Another way to implement the google analytics code manually would be to paste the following code in your current active theme’s functions.php file. Note that you should replace with your tracking code that you have copied from your google analytics account.

<?php
add_action('wp_head', 'add_ga_code');
function add_ga_code() { ?>
<my analytics code>
    
<?php }