How To Add Google Analytics In WordPress Website

It is essential to understand how your website visitors interact with your website and which posts and pages work well. Google Analytics tells you about all your visitors and here we tell you how to add Google Analytics in WordPress Website.

You can do this by tracking traffic statistics on your website by adding the Google Analytics tracking code.

Well, today, in this post, will you learn how to install Google Analytics in WordPress? With and without a plugin [step by step]

But before moving directly to the Google Analytics installation, let’s first understand what Google Analytics is and what its benefits are.

What is Google Analytics?
Google Analytics is a free web analytics tool developed by Google in 2005. It is used to track and report website traffic.

The benefits of Google Analytics include a better understanding of:

1. Type of traffic (or traffic channel)
With the help of traffic channels, you can understand how your website visitors find your website.

The main types of traffic include direct traffic, referral traffic, organic traffic, social traffic, etc.

2. Social platforms
You need to understand which social media platform is bringing the maximum and minimum traffic.

You can prepare strategies for social networks that generate a minimum or less amount of traffic.

3. Amount of traffic
Google Analytics helps you track and report the amount of traffic you’re receiving on your website.

You can check which page or post on your website works well and which doesn’t.

It also allows you to compare the traffic with the traffic of the previous month so that you can calculate the progress of the website.

4. User behavior
You can check which pages a user is landing, how many pages they have visited in that session and how much time has passed.

You can use this detailed insight to optimize your website for more traffic and conversions.

Now that we know what Google Analytics is, let’s understand how to add Google Analytics on the WordPress website.

Integration of Google Analytics in WordPress
Integrating Google Analytics into a WordPress website is super easy and doesn’t require much technical knowledge and can be done even by WordPress beginners.

The Google Analytics installation process is divided into 3 steps:

1.Create a Google Analytics account
2.Add Google Analytics code to WordPress
3.Test the Google Analytics tracking code

We will review each of them step by step.

The first and last step will always be the same regardless of the installation method.

How to register with Google Analytics?
The minimum requirement to create a Google Analytics account is to have a Google account.

So if you don’t have one, first create a Google account to start using Google Analytics. Let’s take a look at the registration process.

Step 1: Visit the Google Analytics signup page.

google-analytics-account-sign-up

You must be signed in with your Google account.

Step 2: Post login, you will be redirected to the Google Analytics welcome screen, where you will find the “Configure for free” button.

google-analytics-welcome-screen-post-login
Step 3: You will be asked to fill in your Google Analytics account details, including account name and data sharing settings.
You can use any name that represents your business or website.

google-analytics-account-name

Step 4: Next, you must select the type of device on which you want to configure your scan account.

Select “Web” for your website and Applications for the Android or iOS application.

google-analytics-for-web-and-app
There is also a third option to select both the web and the apps, but it is still in beta.

Step 5: Lastly, you need to enter the property details including the website name, the URL, the industry your website belongs to and the time zone.

google-analytics-website-property-details
Step 6: You will be redirected to the Google Analytics dashboard where you will find the Google Analytics tracking code.

google-analytics-tracking-code
This tracking code will be used when you install Google analytics with the WordPress plugin.

On the other hand, if you choose to install Google Analytics manually, you must copy the JavaScript code.

How to add Google Analytics to WordPress website using plugin?
I am going to share five methods with which you can configure the Google Analytics tracking code in WordPress with the help of plugins.

I list three methods where you need to install a WordPress plugin to add the Google Analytics tracking code to your WordPress website.

So, let’s go see them.

Method # 1 – Using Google Analytics for WordPress by MonsterInsights
MonsterInsights is among the best Google Analytics WordPress plugins that allow you to install Google Analytics code easily without having any coding knowledge.

Method # 2: Use of the GA Google Analytics plugin
GA Google Analytics is another plugin with which you can easily add the Google Analytics tracking code to your WordPress website.

Like MonsterInsights, you must install and activate the GA Google Analytics plugin.

install-ga-google-analytics-wordpress-plugin

After installation, you need to add the Google Analytics tracking ID to the plugin settings.

For that, go to Control Panel> Settings> Google Analytics> Plugin Settings.

ga-google-analytics-configuration-settings
Add the Tracking ID that we copied in step 6 of the previous section and paste it into the GA Tracking ID field.

Be sure to select –

1.”Universal Analytics / analytics.js” in the tracking method, and
2.“Include tracking code in page head (via wp_head)” in the code location.

Method 3: Add Google Analytics Code Using Insert Headers and Footers Plugin
First, you need to install and activate the Header and Footer Insert Plugin.

install-insert-headers-and-footers-wordpress-plugin

Upon plugin activation, Go to Dashboard > Settings > Insert Headers and Footers.

copy-google-analytics-javascript-code-to-insert-headers-and-footers-plugin

You must paste the Google Analytics JavaScript code (obtained in step 6) into the Scripts field in the header. Save the configuration.

How to add Google Analytics to WordPress blog without plugin?

Method 1: add the Google Analytics code through the file Functions.php
Another method to add Google Analytics code is to add code to functions.php.

add-google-analytics-code-via-functions-php-file

You must insert the following code into your theme’s functions.php file. Be sure to replace the string “TRACKING ID” (2 instances) with your Google Analytics tracking ID.

 <?php
function techguidance_google_analytics() { ?>

// Paste Google Analytics JavaScript code from Step #6
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TRACKING-ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'TRACKING-ID');
</script>

<?php } 
add_action('wp_head', 'techguidance_google_analytics');
?>

Method 2: insert the Google Analytics code into the Header.php file

If you don’t want to use a WordPress plugin, you can directly add the JavaScript code to the header.php file of your WordPress theme.

Go to Control Panel> Appearance> Editor.

Once the editor opens, you need to click header.php to open it in the editor.

Paste the JavaScript code just before the closing </head> tag.

add-google-analytics-tracking-code-in-header-php-file

Save the file and you are done.

How to check if Google Analytics is working?

The last step is to check if Google Analytics is installed correctly and works well on your WordPress website.

You can check it yourself by simply following the steps below:

1.Open your website in the new tab.
2.Open Google Analytics Dashboard and go to Realtime.
3.If Google Analytics is successfully connected to your WordPress website, it will display the number of active users in real time along with the type of device.

real-time-google-analytics-verification

Google Analytics frequently asked questions

1. Is Google Analytics free to use?
Yes. Google Analytics is free to use. Google has also introduced an advanced paid version of GA called Google Analytics 360.

2. What is Google Analytics for?
Google Analytics is used to track traffic metrics, including traffic source, dwell time, bounce rate, average session, and more.

3. Where do I put the Google Analytics code?
We recommend adding the Google Analytics tracking code to the <head> tag of the WordPress website.

4. How to verify google analytics in WordPress Dashboard?
You can check Google Analytics data in your WordPress dashboard by installing the WordPress plugin MonsterInsights.

What method should you choose to add Google Analytics to your WordPress website?

Google Analytics is a powerful tool that plays a crucial role in improving your WordPress website.

It allows you to track and analyze how well your content is performing and help you strategize and improve your content accordingly.

Talking about which method you should choose, as a beginner you can go with MonsterInsights or GA Google Analytics.

If you are familiar with the code of a WordPress expert, you can use any of the above methods, including functions.php or header.php.

In case you have any trouble adding the code to your WordPress website, you can comment them below.

Leave a Reply

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