When setting up websites for clients it’s essential to include Google Analytics in the mix.

Google Analytics allows you to track site visits and gage how the website is performing on a daily, weekly or monthly basis.

WHAT IS GOOGLE’S RECOMMENDATION FOR ADDING THE ANALYTICS TRACKING CODE?

Google’s official recommendation for adding the Google Analytic tracking code is place the tracking code in the HEADER SECTION ( <head>) of the website.

The code should be added near the top of the <head> tag and before any other script or CSS tags, and the string ‘UA-XXXXX-Y’ should be replaced with the property ID (also called the “tracking ID”) of the Google Analytics property you wish to track.

WHAT DOES THE ANALYTICS TRACKING CODE LOOK LIKE?

Google’s Analytics tracking code is referred to as asynchronous code, which essentially means to run in parallel with other scripts that are active on the page.  The advantage of asynchronous code is that if some code is taking a while to run or has an error, other code that is running asynchronous is not effected.

An easy way to image this is to visualize a grocery store where there are multiple lines of people purchasing food rather than just one cashier.  Each one of those lines could represent an asynchronous set code instructions that wouldn’t be dependent on the other lines of shoppers or cashiers.

Google’s Analytics tracking asynchronous code was initially launched back in 2009 when it’s first version of Google Analytics Asynchronous tracking became a reality.

In most cases it’s really easy to tell if a website has Google Analytics installed by viewing the web page’s website code.  I will often use Google Chrome to view a website and then right click to view the website’s PAGE SOURCE (website code).

If the website has Google Analytics installed, there should be the Google Analytics tracking information within the code.

NOTE: Many websites have now employed Google Tag Manager instead of simply Adding Google Analytics, so rather than looking for Google Analytic code you would look for Google Tag Manager code.

Google Analytics Tracking Code

Google Analytics Asynchronous Tracking Code

WHAT DOES THE GOOGLE ANALYTICS TRACKING CODE DO?

The tracking code performs 4 essential tasks.

  1. It creates a <script> element that starts asynchronously downloading the analytics.js JavaScript library from https://www.google-analytics.com/analytics.js
  2. It initializes a global ga function (called the ga() command queue) that allows you to schedule commands to be run once the analytics.js library is loaded and ready to go.
  3. It adds a command to the ga() command queue to create a new tracker object for the property specified via the 'UA-XXXXX-Y' parameter.
  4. It adds another command to the ga() command queue to send a pageview to Google Analytics for the current page.

In reality it tracks website usage by people who visit your website giving you invaluable insight into the pulse of your website.

HOW TO ADD GOOGLE ANALYTIC TRACKING CODE TO YOUR WEBSITE

Now that we know what Google Analytics Tracking Code does, and where to add, how do you go about doing it?

It turns out in most cases it is pretty easy.  The vast majority of content management systems and themes allow for the insertion of Google’s tracking code.

In the Divi Theme, which is the one I am currently using, there is a section designated for tracking code.  Other themes will also have places to add tracking code to.  The best advice is to read your theme’s manual or do a quick Google Search on your specific theme.

Divi Theme Google Analytics Tracking Code WordPress Head Section

Another method is to use one of the various Google Analytics plugins that will help you add the tracking code.

Here is a WordPress plugin called Google Analytics that makes it easy to add the analytic code.  Simply add the plugin and follow the specific directions.

Google Analytics Plugin