Google Analytics was first made available on November 14th 2005, (almost 13 years ago!) its usage quickly grew and within almost no time it became the dominant website measurement tool. The scope of its offerings have expanded to include features and new technologies over time. As new features have become available the code that connects your website to Google Analytics (GA) has changed as well. To help you understand the different kinds of code that are used to deploy GA, we have created this all in one guide.
Quick Snippet Library Reference:
“What the heck is this?” may have been your first reaction to this very, very legacy version of Google Analytics. This has been discontinued for years and was designed into two parts, the “UTM Sensor” which is the code installed on the website, then the IT team was required to connect the Apache or IIS configuration to the “Urchin Tracking Module Engine”. This was a lot of hassle but believe it or not, it was competitive in 2005.
You can detect if a website has Urchin installed by looking for a script with the source “/__utm.js” on the webpage. However finding a website with such old tracking is kind of rare at this point. If your website is using this tool to track website users, then please call us immediately (800-787-0497) for a free consultation. We will also assist with donating your old script to “The National Museum of Truly Old Code”.
Current Usage of Urchin represents less than .1% of the top 1 million sites:
After acquiring Urchin, Google quickly began to build out the cloud based product Google Analytics which includes a familiar white and orange interface.
The code for traditional syntax began to use the “ga.js” library and the code looks like the below:
This code was “synchronous” which means it held up other resources from loading while it executed.
This tracking code snippet should be included in your site’s pages so that it appears at the bottom of the page’s HTML (or generated-HTML) structure, before the closing <body> tag.
Learn more about Google Analytics Traditional Syntax:
After years of refining the platform, the ga.js snippet was updated to make it load “asynchronously” (this means that it would allow other things to load while it was working in the background). This became essential to maximizing the performance of a website and minimizing the footprint of Google Analytics load times by using the “_gaq” object, which works like a queue instead of just executing code. If you see the “_gaq” object in the code then you know it is legacy Google Analytics.
Legacy ga.js Code:
Insert the asynchronous snippet at the bottom of the <head> section of your pages, after any other scripts your page or template might use.
Support is available at https://developers.google.com/analytics/devguides/collection/gajs/.
The current version of Google Analytics is all based on the analytics.js functionality. This library update was accompanied by a more modern interface and new functionality that abstracted configuration from the code and placed it in the interface. Universal analytics was designed to improve things like cross domain tracking while making it possible to process ecommerce returns and even use the Google Analytics Measurement Protocol to push offline information into Google Analytics.
When this product was first announced, many brands fired universal analytics side by side with legacy. It was months later when Google indicated that every Google Analytics property would be automatically transferred to the universal interface automatically.
The snippet for analytics.js resembles the below code:
The GA command queue has been changed from the old ga.js version, instead of being a “_gaq” array, the commands are queued up by using a “ga()” function. This code can be easily identified by looking for the script source https://www.google-analytics.com/analytics.js.
While universal analytics and analytics.js created many new features, it also removed some components that advanced level GA practitioners found useful. The primary example of this is the UTM cookies that store referral data in an easy to access cookie. We have blogged about the UTM cookies available through ga.js previously. All of these cookies have been replaced with a single “_ga” cookie that identifies the user with a “client id”.
The code should be added near the top of the <head> tag and before any other script or CSS tags.
Support is available at https://developers.google.com/analytics/devguides/collection/analyticsjs/.
Google Tag Manager is deployed using the following code in two parts:
Part 1: This part of the code is deployed as close to the opening <head> html tag as possible (replacing GTM-XXXX with your container ID):
Part 2: This part of the GTM code is deployed immediately after the opening <body> tag (replacing GTM-XXXX with your container ID):
Support is available at https://developers.google.com/tag-manager/quickstart.
The latest GA snippet is gtag.js, it is not as flexible as using Google Tag Manager but it is the current default snippet that is supplied by the Google Analytics interface. The gtag.js snippet is different from analytics.js in that it can be used to send information to AdWords and DoubleClick in addition to Google Analytics.
Our recommendation is to forego gtag.js and use Google Tag Manager since it can do anything that gtag.js can do and more.
Recommended placement is immediately after the opening <head> tag.
Support is available at https://developers.google.com/analytics/devguides/collection/gtagjs/.
After you have located and identified how you are deploying Google Analytics on your website you may have questions about using it to get more data from your website. MoreVisibility can help you analyze your current data or upgrade your tracking to get a better understanding of what marketing works best. Please reach out to [email protected] or fill our form for a complimentary consultation.