Web analytics is the process of analyzing visitor behavior on a website. It is used to measure web traffic, identify target markets, optimize marketing campaigns, and count visitors. The process involves defining goals, building key performance indicators, collecting data, analyzing the data, testing alternatives, and implementing changes. Critical metrics include visits, time on site, bounce rate, exit rate, conversion rate, and engagement. Web analytics works by tracking user activity via JavaScript and sending data to an analytics server for processing, storage, and reporting.