ELI5 Technical Tuesday: How To Install Google Analytics On WordPress

ELI5 Tuesday, How To, Websites

On today’s internet, one of the most important things you can do is have Google Analytics for your website. Having the power to see how many people view your site, what they click on and how long they stay is invaluable when optimizing a website for lead generation or user experience. If you have a WordPress website there are 3 main ways to add Google Analytics tracking codes, which are responsible for recording the data from all visitors when they come to your website.

Before You Do Anything

We need to register for a Google Analytics account. This is where you will be able to log in and view your data, create goals and track conversions.

  • Go to Google Anayltics registration page
  • Login with Google email login
  • If you are completely new to Google, you will need to create a full Google account first
  • Once you sign in it will prompt you to sign up for an analytics account
  • It will then take you through a process where you have to enter your website information
  • Once you complete the process a Google Analytics tracking code will be generated, this is what we came here for. The point of this code is that it needs to be on every single page of your website to track all data.
  • Leave this page open until you finish the installation on your website
  • It will look something like this:


var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXX-X’]);
_gaq.push([‘_trackPageview’]);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

Option 1) The WordPress Plugin Method

Personally, as developers we try and stay away from plugins here at OCT but for this ELI5 guide, we recommend using this method as it is by far the easiest for novice WordPress users. That being said there are easily 20+ plugins out there that can accomplish this goal, my personal favorite though is a very lightweight plugin that allows you to easily input code into the header. Don’t worry if you dont know what that means. Follow these steps for this option
-Download and install the Insert Headers and Footers plugin

  • Go to Settings on your dashboard
  • Select Insert Header and Footer
  • Copy and Paste Google Analytics Tracking code in the Header box
  • Save

Option 2) Directly Add To Code Header.php File

Ill start by saying, if you do not know what the Header.php file is, this method isn’t for you. This is for people who have a moderate understanding of WordPress back end functions.

  • Navigate to header.php from your dashboard using Appearance > Editor > header.php
  • Paste your tracking code directly after the first tag
  • Save

Notice: If you change your theme this code will need to be redone. It can also be overwritten when updating a theme.

Option 3)  Add The Code To Your Website’s Functions.php File

I will again start by saying, if you don’t know what Functions.php file is, this option isn’t for you. This is for people who have a moderate understanding of WordPress back end functions. Be very careful when editing your websites PHP.

  • Navigate to Functions.php from your dashboard using Appearance > Editor > functions.php
  • Add a function in the PHP to call the tracking code
  • Paste Analytics tracking code where noted
  • Save

Notice: If you change your theme this code will need to be redone. It can also be overwritten when updating a theme. This method also requires direct modification to the PHP. If you do not input the proper syntax you can white screen you whole website. That is bad, don’t do bad things to your website unless you understand PHP syntax.

Once  You Have The Code Installed

Navigate back to your open Google Analytics webpage and hit save. After a few days you will be able to start analyzing meaningful data on your website and how users are interacting with it. For data nerds like myself, Google Analytics is the holy grail of website analytics data. It affords many customization features that can be leveraged to do some pretty cool predictive monitoring of your website and it’s content.

Want This Handled By An Expert?

Get back to your job and get this handled by a professional.
Yes, I Need Help!

Choose Oak City Tech, Your Local Web Design & SEO Company

We're local to the Raleigh/Durham/Chapel Hill area known as RTP, we take in person meetings, and we love to help local businesses and organizations succeed online. Contact us today and let us know how we can help you. We're serving actual local businesses and organizations and they're talking about us online.

Not Ready To Get Started?

We can still help you attract new business while working to grow revenue from existing clients and strategic partnerships. Get actionable advice & information right in your inbox from industry experts and professionals. 


Home     Who we are     Blog     Contact     Web Design & Development     SEO     Website Maintenance     Branding & Logo Design     Social Media Marketing     Content Marketing     Website Hosting     You are here: Home » ELI5 Tuesday » ELI5 Technical Tuesday: How To Install Google Analytics On WordPress

Google Creative Certified

Google Analytics Certified