Fundamentals
How Web Tracking Actually Works: Pixels, Cookies & Hits
Most tracking problems get a lot easier to debug once you understand what's actually happening under the hood: how a page load turns into a "hit," how a tool recognizes a returning visitor, and why two analytics tools never quite agree. This is the mental model the rest of GTM builds on.
A page load is a sequence, and timing matters
When a browser opens a page it requests the HTML, parses it into the DOM, and runs scripts as it goes. GTM loads asynchronously near the top and fires a sequence of built-in events as the page progresses:
gtm.js, the container has loaded and can start firing.gtm.dom, the DOM is ready (the DOM Ready trigger).gtm.load, the window has fully loaded, images and all.
A tag that reads page content must fire after that content exists. Choosing the right moment is half of getting a tag to work, and the source of many "it's undefined" bugs.
How a tag sends data: the "hit"
A tag's job is to send a request to a vendor with some parameters. Under the hood it's a tracking pixel, a fetch, or a sendBeacon, but the idea is always the same: encode the data into a request and send it to a collection endpoint.
https://www.google-analytics.com/g/collect ?v=2&tid=G-XXXX&en=purchase&ep.currency=USD&epn.value=49
Debugging superpower
collect) and you'll see one request per hit, with the event and parameters in plain sight. "Tag fired" is not the same as "hit sent", the Network tab shows the truth.How tools recognize a visitor
To attribute a series of hits to the same person, a tool stores an identifier in a first-party cookie. GA4 keeps a client id in the _ga cookie and attaches it to every hit.
- Client id: identifies a browser, stored in a cookie.
- Session: a time-bounded group of activity that ends after inactivity.
- User id: your own logged-in identifier, which can stitch sessions across devices.
Because this rests on cookies, anything that clears or shortens them, privacy settings, different devices, incognito, fragments the picture. That's the root cause of many "why are users inflated?" questions.
Practice this on a real container
Reading what actually leaves the browser is the skill that makes everything else click. Practice pushing data and reading it back, then watch the hit in the Network tab, on your own container.
Practice reading the dataLayer →Why two tools never agree
Attribution decides which marketing touchpoint gets credit for a conversion. Two choices drive it: the lookback window (how far back to consider touches) and the model (how to split credit). A click-based ad platform and a session-based analytics tool use different windows and models, so their conversion counts legitimately differ. That's expected, not a bug.
Why tracking breaks
Tracking is fragile because it depends on the browser cooperating. The usual suspects:
- Ad and tracking blockers that stop vendor requests entirely.
- Browser privacy features (ITP, ETP) that shorten or clear cookies.
- Consent denial, so tags hold or run cookieless.
- Single-page apps that change the URL without a real page load.
- Tags firing before the data they need exists (race conditions).
The resilient answers, server-side tagging, first-party data, robust triggers, firing on confirmed events, all follow from understanding these mechanics.
Now go practice it
Reading sticks when you do it. These hands-on lessons load your own GTM container and let you debug in Tag Assistant.
Frequently asked questions
How does web tracking actually work?
When a page loads, tags fire requests (pixels, fetch or sendBeacon) that encode data and send it to a vendor's collection endpoint, that request is a 'hit'. Tools recognize a returning visitor by storing an identifier in a first-party cookie and attaching it to every hit, which lets them group activity into sessions and attribute conversions.
What is a tracking pixel?
A tracking pixel is one way a tag sends data: a tiny request (historically a 1x1 image, now often a fetch or sendBeacon) whose URL or body carries the event and parameters to a vendor endpoint. You can see these in the browser's Network tab.
Why do GA4 and my ad platform show different numbers?
They use different attribution windows (how far back they look) and models (how they split credit), and one is session-based while the other is click-based. The same conversion is counted under different rules, so the numbers legitimately differ. Reconcile each tool against itself rather than expecting them to match.
Why does tracking break so often?
Because it depends on the browser cooperating. Ad blockers stop requests, browser privacy features shorten or clear cookies, consent denial holds tags, single-page apps change the URL without a real page load, and tags can fire before their data exists. Server-side tagging, first-party data and robust triggers harden against these.
Related posts
Fundamentals
What Is the dataLayer in Google Tag Manager? A Plain-English Guide
The dataLayer is the bridge between your website and your tags. Here's what it actually is, why it exists, and how to push and read values without the jargon.
Read →Fundamentals
GTM vs GA4: What's the Difference (and Do You Need Both)?
Both come from Google, both involve a snippet, but GTM and GA4 aren't alternatives. One delivers data, the other analyzes it. The difference, and why you use both together.
Read →Fundamentals
What Is Google Tag Manager? A Plain-English Guide for Marketers
Everyone's told to 'just set up GTM' with no explanation of what it does. In plain terms: it's a control panel for your site's tracking, so you change tags without editing code.
Read →About the author

Analytics & Tag Management Consultant
Nathan Gage got his start in marketing through Google Tag Manager. Seeing how tracking customer behavior could turn raw clicks into insight you can actually act on is what pulled him into the field. Since then he has worked both full time and as a consultant with 15 marketing agencies, supporting brands that spend anywhere from a thousand dollars a month to over a million. Along the way he built a multi-touch attribution app, and he created The Happy Tagger so anyone can practice GTM, GA4 and server-side tracking on a real container instead of a production site.