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.
<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.
WHAT DOES THE GOOGLE ANALYTICS TRACKING CODE DO?
The tracking code performs 4 essential tasks.
- It creates a
- It initializes a global
gafunction (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.
- It adds a command to the
ga()command queue to create a new tracker object for the property specified via the
- 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.
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.