How To Integrate Google Analytics In WordPress Backend

How To Integrate Google Analytics In WordPress Backend

Google Analytics

Google Analytics is a free Web Analytics program that gives information and data about traffic and related measurements of a website. Google Analytics generates detailed statistics about a website’s traffic (volume and origin), measure conversations and sales. Google Analytics is great at tracking your website’s traffic but not so great for automatically downloaded content such as PDF, MP3, MS Word documents and videos due to its reliance on JavaScript. In this article, I will show you why Google Analytics is important and how to use it on your website.

Google Analytics

The Importance of Google Analytics

Google Analytics track two important visitors’ behavior

Where the visitors are coming from: – Very important if you are targeting a specific audience.

What they do when they are at your website: – You can easily track the pages that the visitors access and how long do they stay on the website.

How to Sign up for Google Analytics

First, you need to create a Google Analytics Account. To do this, visit Google Analytics SignIn. If you already have had a Google account, sign in. If you do not have an account, create it before doing anything else.

Login your account

Getting The Tracking Code

When you add your site to your Google Analytics account, you are given a tracking code that you need to insert into your website’s pages so that Google can track visitors on each page.

Your account will be selected automatically on the left and you will need to add your website to the PROPERTY column in the center.

Property

Creating a new property will provide you with a Tracking ID.

Tracking ID

Once you have done, you can copy the tracking code from the admin section of the Analytics site.

Get tracking code

How to Install Google Analytics at Your WordPress Site

In this step, I will show you how to install Google Analytics at your WordPress site. There are three ways of installing Google Analytics at WordPress sites.

  • Plugin Method
  • Direct Paste Method
  • Function.php Method

Plugin Method

You will find many plugins for Google Analytics. However, I recommend Google Analytics Dashboard For WP. This Google Analytics for WordPress module permits you to track your site utilizing the most recent Google Analytics and permits you to view key Google Analytics reports in your WordPress Dashboard.

From your “WordPress Admin Panel” navigate to “Plugins >> Add New.”

Add new plugin

In the top right search bar for “Google Analytics Dashboard for WP”, once it is found, click on “Install Now.” After installing, click on “Activate Plugin.” For reference, check the image below.

Activate Plugin

After activating the plugin, you will see “Google Analytics” menu at the left side on WordPress dashboard.

Authorize the plugin to connect to Google Analytics using the “Authorize Plugin” button

Authorize Plugin

After that, click on the link to get the access code.

Get access code

Copy this code.

Copy Code

Switch to your application and paste it there.

Paste Code

Google Analytics is now installed and ready to collect data on your website.

Google Analytics installed

Direct Paste Method

This is the Universal Analytics tracking code for this property.

To get all the benefits of Universal Analytics for this property, copy and paste this code into every webpage you want to track. Paste it near the top of the <body> tag.

<script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
 })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
 ga('create', 'UA-77134696-1', 'auto');
 ga('send', 'pageview');
 </script>

Direct Paste Method

Function.php Method

Only use this method if you are well versed in PHP coding. Add the following code in your theme >> function.php file. Don’t forget to paste your Google Analytics code in your function.php file.

<?php
 add_action('wp_footer', 'add_googleanalytics');
 function add_googleanalytics() { ?>
 // Paste your Google Analytics code from Step 4 here
 <?php } ?>

Function.php Method

Final Words

Thank you for your time. I hope this article helps you in integrating Google Analytics in WordPress backend of your site. If you have any query or suggestion about this tutorial, I would appreciate if you could leave a comment.

As far as hosting is concerned for your website, my recommendation is Cloudways Managed WordPress Hosting Platform which helps you achieve good search engine rankings by speeding up your website. Launch your free trial today to test the Platform which is getting rave reviews from the WordPress community.