How to add Google Analytics WordPress: Beginner's guide »Compa Marketing

How do I add Google Analytics to WordPress? If this is something you have been searching for a while, then your search ends right here. Because in this tutorial, here at the TemplateToaster WordPress theme builder blog, I will show how you can easily use Google Analytics WordPress and know how your audience interacts with your website. your.

It is a good practice to use Google Analytics in your WordPress site to track performance. You can thoroughly analyze what is working on your site and what is not. And accordingly, you can strategize your marketing campaigns to attract potential users to your site. It allows you to optimize your website and gain a deeper understanding of your customers.

What is Google Analytics?

Google Analytics is a free tool that helps you analyze your website traffic. No matter what type or size of business you have, Google Analytics provides you with mandatory information that can help you optimize your WordPress site for better results. Insights such as the source of your traffic, the number of visitors, the most visited page on your website, and many other reports help you effectively increase your marketing with Google Analytics.

Benefits of adding Google Analytics to WordPress

Google Analytics helps you make decisions based on data. Obviously, when you have accurate statistics about your website, you can easily implement your strategies. Google Analytics can help you do the following.

  • The first reason to add Google Analytics WordPress is that it is a completely free tool. So you do not need to spend anything.
  • It tells you the exact source for the traffic.
  • You can track at the time you are getting maximum visitors on your site. Or what is the peak hour of your site.
  • How do visitors find your site?
  • Who is accessing your website? You can track visitors based on country or IP Address in WordPress.
  • What are visitors doing on your website?
  • How long and more specific are they staying on your site?

I am sure these are sufficient reasons to add Google Analytics to WordPress. This is one of the most reliable tools you can use for your website. Now that you know what Google Analytics is and what are the benefits of adding it to your WordPress site. This is the time to learn the methods to set it up.

How to add Google Analytics to WordPress

The choice of method is entirely yours. I will show you how many ways you can achieve this. And yes, by the end of this article, you will be fully equipped with some authentication ways to successfully add Google Analytics to WordPress. So let's get started.

Follow these simple steps to add Google Analytics to WordPress

Step 1: Create a Google Analytics account

To register for a Google Analytics account, you must have a Gmail or Google account. So, if you do not have a Google account, please create one.

That's it! You have successfully signed up for Google Analytics.

Step 2: Install Google Analytics WordPress

Now that you have signed up for Google Analytics, now the next important thing is to add Google Analytics to your WordPress site. And we have a few ways to add Google Analytics to WordPress and you can get started with whatever method you find easy and useful according to your needs. The two methods are:

  1. Add Google Analytics WordPress using Plugin
  2. Add Google Analytics WordPress manually

Now I will show you how you can easily use both methods. Let's start with it.

How to add Google Analytics to WordPress with the Plugin

Using plugins makes it easy to add Google Analytics to WordPress without even touching a single line of code. However, there are many Google Analytics plugins to choose from and I'm discussing here MonsterInsights. It is one of the most trusted and widely used Google Analytics plugins with over 2 million active installs. I assume you know how to install WordPress plugins. The basic version of MonsterInsights is free and it includes pretty good features. But if you want more, you can use the Pro Version that comes with a 14-day money back guarantee.

Follow these steps to add Google Analytics with the MonsterInsights Plugin

Step 1: Install the Plugin

First, you need to install the plugin. Go to your WordPress dashboard, go to Plugin → Add New. Search for the MonsterInsights plugin and click Install as soon as you see it. And finally, click Activate to move forward.

add wordpress Google Analytics with the MonsterInsights Plugin

Step 2: Configure the Plugin

After you have successfully installed and activated the plugin, you now need to configure it. Because once it is configured correctly, you will be able to communicate with your Google Analytics account.

Go to Settings in the left menu bar and navigate to Details → Settings to authenticate your entered Google account.

Step 3: Verify your Google account

To authenticate your Google account, click on the ‘Verify with your Google account’ button and you will be taken to the Google login page again. You only need to fill in the information asked and click the 'Next' button to continue.

Configure the Google Analytics WordPress Plugin

You need to ‘Allow‘ MonsterInsights plugin to access Google Analytics Control Panel and the data in it. That's it! You will now begin to see your website tracking data within 24 hours.

Some other popular plugins to add Google Analytics to WordPress

  1. Google Analytics for WP Control Panel of ExactMetrics (formerly GADWP)
  2. GA Google Analytics
  3. Google website set
  4. Google Analytics Dashboard Plugin for WordPress by analysis

How to add Google Analytics WordPress manually

Adding manually Google Analytics WordPress needs some basic coding knowledge. Therefore, it is suggested that advanced users who are familiar with encryption should use this method. Similarly, make sure you are using a sub theme in WordPress to add customizations. Because if you do not use subtopics then all the changes you will make will be overwritten in the main thread as soon as you update your theme.

Before we head to the topic files, it is essential that we fetch the Google Analytics Tracking Code from the Google Analytics dashboard. Just follow the steps below to do so.

  • Log in to your Google Analytics account and click on ‘Admin’ in the left menu bar.
  • Click on ‘Traffic information’ and select ‘Tracking code’ from the submenu here.
  • You should now see the tracking ID and tracking code. Just copy the tracking code from here.
  • Now go to the WordPress dashboard for further processing.

The main benefit of adding tracking code in the header.php file is that it will load on every page. So to add the tracking code, you need to follow these steps.

  1. Go to your WordPress dashboard and go to Themes → Theme Editor
  2. From the right column open the header.php file
  3. Now, before closing the tag , paste the tracking code you copied from your Google Analytics account.
  4. After you paste the code, click the ‘Update file’ button to confirm.

That is all! You have successfully added Google Analytics WordPress.

Add the Google Analytics code in the file.php.

You can also add Google Analytics code in the file.php. All you have to do is edit the subfile.php file and include the code provided below for it. (Make sure to replace the tracking ID with your own tracking ID)

my_google_analytics () function {?>