Friday . 08 Dec. 2023

How to add Google Analytics to WordPress with and without plugins?

How to add Google Analytics to WordPress  with and without plugins?

 In this article, we are going to discuss how to add google analytics to WordPress with and without plugins.

Knowing your audience's interaction is very important for the success of your website. You can easily track your audience's behaviour with a free tool by Google called Google Analytics. If you are running your own WordPress website, you should definitely know how to add Google Analytics to WordPress.

What is Google Analytics and what are its uses?

Google Analytics is basically a free tool by Google for tracking your web traffic.  It was launched in November 2005 and is currently, the most used web analytics on the web.

Check this article on How to create and sign in to Google Analytics.

Uses of Google Analytics

Helps to study the behaviour of web traffic

It is a versatile tool that helps to study and analyze the behaviour of your web traffic. Google Analytics is currently present on over 50M websites around the globe.

 It works with the addition of a piece of JavaScript code to your page and this piece of code allows Google to track overall activities of the traffic coming to your site.

You can get information on:

All the geographical as well as technical information about your visitors and the device they use to visit your site.

It tracks the bounce rate, which page they looked at, how long they stayed on your site and many more.

It provides information about when people are visiting your site by hour, day, week and month.

It is also capable of tracking how the audience was able to find your site like social media or link or through search engines.

Use of information to optimize the website.

All those information are very helpful to optimize your website. You can adjust your site according to your audience's response. Studying those metrics helps in content and product selection. You can make a good effort on the topic that your visitor is interested than on the topic they aren’t. A marketing campaign can be tracked and observed easily if they are working well. Last but not the least, you can find out all of your faulty pages and fix it for better performance.

How to add Google Analytics to WordPress?

There are different method to add Google Analytics to WordPress but we will discuss three methods here. You can choose one that suits best for you.

1. Google Analytics by MonsterInsights

MonsterInsights is one of the most popular Google Analytics plugins for WordPress. This plugin is used by over 1M websites all around the globe. One reason for its popularity is that it is the best and the easiest way to add Google Analytics to WordPress.

 It is available in both free and premium version but we will be using its free version. If you need advanced features like Ads tracking, eCommerce tracking, author tracking etc you can use its pro version.

MonsterInsights plugins for Google Analytics

Now, let's see the setup process.

 The first thing to do is to install and activate the plugin. After the activation process, you can see a new menu item " Insights" to your WordPress admin menu. Simply click on it to go to MonsterInsights setup wizards.

It will ask you to select a category for your website ( Business, Publisher or Ecommerce ). Select one of the options and click " Save and Continue" button.

Now, click " Connect MonsterInsights" and you will be taken to your Google accounts. Select or sign in with your Google account and click " Allow" to allow MonsterInsights to access your Google Analytics account.

The last step is to select a profile for the tracking process. Select your website and click " Complete Connection" button.

Now, Google Analytics will be installed on your website by MonsterInsights and you will be asked to select the recommended settings for your site.

The default settings would be enough for most of the site except if you are using an affiliate link plugin. You should add a path that you use to cloak affiliate links to allow Google Analytics to track your affiliate links.

 Click " Save and Continue" for saving your settings. Now, MonsterInsights will show paid add-on available on its pro version. Simply click " Save and Continue" to skip the process.

After this, you are asked to install WPForms plugin. You can simply press " Skip this Step" to skip the process.

Now, you have successfully added Google Analytics to WordPress.

Note: It may take some time by Google Analytics to start showing your stats.

You can view your Analytics report inside your WordPress dashboard in the section Insights >> Reports.

2. Add Google Analytics in WordPress Theme

This method is little advanced and is particularly for the person familiar with code. This method is somehow unreliable because code gets lost if you update or switch the theme. This method is the least recommended method of all.

Add code in header.php file

You can simply edit header.php file in WordPress theme and copy the code ( available while signing in to Google Analytics account) right after the < body> tag and make sure to save the changes and upload the file back to the server.

Add via function file

Google Analytics tracking code can also be added to WordPress function file and tracking code will automatically be added to every page on your site.

Add this code to theme's function.php file

Google Analytics codeSource:

3. Insert Headers and Footers plugin

This method is not so good as a plugin because you will not be able to view your analytics on the dashboard.

First, you will need to install and activate Header and Footer plugins. 

Now go to Settings >> Insert Headers and Footers page and paste the Google Analytics code into the headers section ( code available while signing in to Google analytics account ).

Finally, click on the save changes to save your settings and Google Analytics will be successfully get installed on your site.

Add Google analytics code in Header and Footer sectionSource:

More on Google Analytics

Google Analytics is capable of providing tons of data from your stats and this data can be viewed on Google Analytics dashboard. You can see 5 different tabs -Real-time for a real-time view of your traffic, Audience for understanding your users, Acquisition to explore a place, Behaviour to learn about modes of users arrival and conversion to show how much you are close to your goal.

Readers Comment