Google Analytics works by tracking pages with special code. Most websites use it by including a JavaScript snippet in the header of the HTML code of the page, hidden from the eyes of website visitors. When the page loads, the code sends information to Google about where the visitor came from, what he or she clicked on, and other demographic data like web browser and location.