June 10, 2024, written by
Andrii Minchekov
This article explains how 📊Google Analytics cookies track your every move across websites once you give consent. Discover the intricate client-server interactions, the role of unique Client IDs, and the detailed process of data collection and analysis. Learn what specific data are collected, including page views, document locations, referrers, document titles, and browser/system information, to provide insightful analytics.
Google Analytics client-server interaction scheme
The sequence diagram illustrates the interactions between the user's browser, the website using Google Analytics, the Google Analytics script, and the Google Analytics server. It highlights the key role of the Google Analytics cookie in tracking user behavior across different websites.
User Visits First Website:
www.example.com
which uses Google Analytics script. User Visits Another Website:
www.example.com
to another site that uses Google Analytics, such as www.anotherexample.com
.Web Page Loading:
www.anotherexample.com
, it executes the Google Analytics script included in the webpage.Script Execution:
Data Collection Initiation:
www.anotherexample.com
.Data Collection and Cookie Access:
Sending Data to Google Analytics Server:
Data Processing by Google Analytics Server:
When data is sent to Google Analytics servers, it includes information derived from the Google Analytics cookie and additional details collected by the GA script. This data is part of an HTTP request.
Client ID (from Cookie):
123456789.987654321
Pageview Hit Type:
pageview
Document Location URL:
http://www.example.com/about
Document Referrer:
http://www.google.com
Document Title:
About Us
Browser/System Information:
Here's a simplified representation of how this data might be structured in an HTTP GET request to the Google Analytics servers:
GET /collect?v=1&tid=UA-000000-2&cid=123456789.987654321&t=pageview&dl=http%3A%2F%2Fwww.example.com%2Fabout&dr=http%3A%2F%2Fwww.google.com&dt=About%20Us&... HTTP/1.1
Host: www.google-analytics.com
v=1
- Version of the measurement protocol.tid=UA-000000-2
- The tracking ID / property ID.cid=123456789.987654321
- Client ID from the GA cookie.t=pageview
- Type of hit, here a pageview.dl=http%3A%2F%2Fwww.example.com%2Fabout
- Document location URL, URL-encoded.dr=http%3A%2F%2Fwww.google.com
- Document referrer, URL-encoded.dt=About Us
- Document title.This structured data is sent via a background HTTP request, typically initiated by JavaScript on the webpage, and is processed by Google Analytics to provide insights into user behavior and website traffic.