Google Analytics works by collecting data through a tracking code embedded in the website's code. This tracking code gathers information about user interactions, such as page views, clicks, and transactions. The data is then processed and displayed in the Google Analytics dashboard, where businesses can analyze it through various reports and metrics.