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.
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.
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.
Creating a new property will provide you with a Tracking ID.
Once you have done, you can copy the tracking code from the admin section of the Analytics site.
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.â
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.
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
After that, click on the link to get the access code.
Copy this code.
Switch to your application and paste it there.
Google Analytics is now installed and ready to collect data on your website.
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>
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 } ?>
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.