Reading list
- Review how web tracking works.
- How Analytics collects data for websites.
- How cookies are used to distinguish users on your website.
Notes
To track data from a website, Analytics provides a standard snippet of JavaScript tracking code. This snippet references a JavaScript library called analytics.js that controls what data is collected.
You simply add the standard code snippet before the closing tag in the HTML of every web page you want to track. This snippet generates a pageview hit each time a page is loaded. Itâs essential that you place the Analytics tracking code on every page of your site. If you donât, you wonât get a complete picture of all the interactions that happen within a given website session.
The Analytics tracking code executes JavaScript asynchronously, meaning that the JavaScript runs in the background while the browser performs other tasks. This means that the Analytics tracking code will continue to collect data while the browser renders the rest of the web page.
As the tracking code executes, Analytics creates unique identifiers to distinguish between users. There are different ways an identifier can be created. By default, the Analytics JavaScript uses a first-party cookie, but you can also create and use your own identifier.
When a page loads, the JavaScript collects information from the website itself, like the URL of the current page, and GCLIDs to be read by other Google products. The JavaScript also collects information from the browser, such as the userâs language preference, the browser name, and the device and operating system being used to access the site. All of this information is packaged up and sent to Googleâs servers as a pageview hit. This process repeats each time a page is loaded in the browser.