Table of Contents
The Basics
In the simplest terms, JavaScript-based tracking programs use a tag on every page of a website to send information about the page being visited and the user to a data collection service. The data is then processed and made available in a reporting dashboard, usually on a delay of anywhere between a few minutes to 48 hours.
Some of the things that are commonly collected, and subsequently available in reports, are:
- User’s browser information – A wide array of information is “available” to JavaScript and by the data collection service request about a user’s browser. Some of the common things captured are:
- Browser program and version number
- Operating system and version number
- Viewport width and height
- Computer screen width and height
- User’s IP address, which provides geolocation and internet service provider information
- Page Referrer – The page referrer is the technical name for the where the user came from. If the user came from Google, then that information will be captured. If the user directly typed in your homepage, then the page referrer will be empty.
- Page Information – Information about the page including the title and URL.
- Request Time – A timestamp record for the time of the user request for the page.
In order to properly collect information for every user and for every page, the tags must be on every page, the user must have JavaScript enabled (this isn’t a requirement for some analytics programs), and the user must have cookies enabled (usually third party cookies are required).
A quick example
Let’s say a new visitor comes to your website and lands on your homepage. Because this user is new, your analytics program hasn’t saved any cookies on this user’s computer yet. The Javascript analytics tag on your homepage starts gathering information about the user and the page.
More in-depth
An understanding of the more technical aspects of how analytics programs work can help a marketer gain a better understanding of what user behavior is possible to track and what the limitations are.
How the JavaScript Tag Works
Including a JavaScript tag across an entire site is what allows analytics programs to track user behavior. The tag uses some JavaScript functions to gather information about users, sessions, pages, events, and cookies. Once the information is gathered, it is compiled in a structured way and an image pixel is embedded in the page. The image pixel points to the data collection endpoint of the analytics program. Once the user’s browser attempts to load this image pixel, all of the data is sent to and collected by the analytics program and stored for processing.
How Cookies are Used
Cookies are necessary for analytics programs to correctly keep track of users. They allow users to be tagged with unique identifiers in the cookies. This allows the programs to know that subsequent webpage requests or events are from the same user and tie them together. Cookies are what allow funnel reports, unique visitor counts, session times, and time on page stats to be possible.
Limitations of JavaScript Tracking Tags
As with any marketing technology, there are limitations to JavaScript tag based analytics programs.
The most obvious drawback is that users with JavaScript disabled won’t and can’t be tracked. Some analytics programs have a way of falling back in this case and will fire a simpler image pixel to collect some data when available.
The second drawback is that no JavaScript tag will fire correctly every time and the results will never be 100% accurate. Sometimes there are network errors, slow internet connections, network timeouts, JavaScript tag conflicts, and a whole list of other reasons the tag will not fire.
Next steps
Now that you’ve got the basics of how analytics programs work, you can get to work defining your analytics goals.