How to add google analytics code in WordPress

Google Analytics is a web analytics service offered by Google that tracks and reports website traffic, currently as a platform inside the Google Marketing Platform brand.

Google analytics collect and let us to analyze stats regarding the blog/web site. As all website owners willing to bring more traffic to the website, this will help us to make decisions based on the stats.

There are built in WordPress plugins to achieve this. Apart from that I am going to do it manually.



Lets see how to add Google Analytics to WordPress without a plugin. Open up your function file or site specific plugin file and add below code snippet.

01. Add via functions.php file

function nerodev_google_analytics() {

// Paste your Google Analytics code here

} 
add_action('wp_head', 'nerodev_google_analytics');

This code will add your google analytics code to header section of your website. Even you can add this code to header.php file.

Other than this there are many ways to add this code to the website.

02. Add google analytics code using a plugin

There are many plugins supports to add this google analytics code to the website. Most famous plugin to achieve this is MonsterInsights plugin. Please follow the our guide on how to install a plugin WordPress. You just need to follow the plugin guidance to achieve this.

How to add Google Analytics code using Header and Footers plugin.

First you want to install Headers and Footers plugin. Please follow the our guide on how to install a plugin WordPress. Once install and activate the plugin just navigate to Settings > Insert Headers and Footers. Then paste your Google Analytics code in the header section and click on Save at the bottom of the page.

You can follow any of the method to add Google Analytics code to WordPress. Once you’re done just check the website to confirm it has been added to your website.

Hope you enjoyed the tutorial. Happy learning ahead.

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *