From a push to a Google hit
The same page view can go to two places. Here is how a line pushed onto window.dataLayer becomes a request to google-analytics.com, and what that request carries.
What a beacon actually sends follows that request to this site's own API. That is the first-party path: a body I wrote, sent to a route I run, enriched by a server I control.
Most sites have a second path, and so does this one. The same page view can also go to Google Analytics. That path starts with an ordinary JavaScript array and ends with a request to a host this site doesn't own. The dataLayer lab shows each step live. Open it in another tab and follow along.
The dataLayer is a queue, not a report
window.dataLayer is just an array on the page. Pushing onto it sends nothing. It's a to-do list that Google Tag Manager reads later.
The gtag() function is still only a few lines, and it runs before any Google code arrives. This site keeps it as a consent shim. Consent Mode reads an arguments object, so a plain array would be ignored:
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
A page view does not call that function. The site pushes an object. That appends the object to the array and returns. It does not call Google:
dataLayer.push({ event: "virtual_page_view", page_path: "/" })
The container reads the queue
The real work starts when gtm.js loads from googletagmanager.com, for container GTM-NCP2JHJR. This site does not load gtag.js. Google Analytics 4, measurement id G-JDE6BF33RY, is a tag inside that container. The container replaces dataLayer.push with its own function, then works through whatever is already waiting, in order. Each command means something different:
consentchanges the gate. The shim pushes it. After Accept, analytics storage is granted and advertising storage stays denied.- A navigation is a
virtual_page_viewobject, not aconfigcall and notgtag('event', 'page_view'). The container maps that event to a GA4page_view. The GA4 tag should not send a page view of its own, or the visit would be counted twice. - Other events are objects with an
eventkey, and each one becomes a measurement. segment_updatecarriessegments, the comma-separated list of segments this browser currently matches. In the container, that value is the GA4 user propertysegments. This site does not callgtag('set').
One more small decision: the page drops the container's automatic gtm.scrollDepth event, so it doesn't double the site's scroll events, which fire the first time a page crosses 25, 50, 75, and 90 percent.
Consent decides whether the container loads at all
On this site, a visitor who hasn't accepted measurement doesn't get Google Tag Manager. gtm.js loads only after Accept, and the site holds back event pushes until then too. A denied visit produces no collect request, and no _ga cookie gets written.
The lab still lets you see what would happen. Press one of the Try it buttons with consent off and the pipeline shows the push, then stops at the consent check with a blocked network step. Those denied rows never reach the real queue, so the container never sees them.
That's the same idea the beacon notes ended on. Building an event, showing it to you, and sending it are separate decisions.
What the hit carries
Accept, press Try it again, and a request goes to https://www.google-analytics.com/g/collect. A virtual_page_view push should arrive on that request as page_view. The lab captures it by wrapping sendBeacon, fetch, and XMLHttpRequest, with a PerformanceObserver as a backup, then decodes it beside the push that caused it.
Most of the meaning sits in a handful of short keys, in the query string, or in the body when several events are batched together:
| Key | What it is |
|---|---|
en | Event name: page_view, click, scroll, and the rest. A virtual_page_view push is mapped to page_view. |
tid | The measurement ID of the property. On this site it's G-JDE6BF33RY. |
cid | Client ID. After consent, Google keeps it in the _ga cookie so later hits from this browser can be tied together. |
sid | Session ID for the current visit. |
gcs | Consent state. |
dl | Document location, the page URL the hit is about. |
dt | Document title. |
ep.* | Event parameters, such as ep.page_path, ep.percent_scrolled, or ep.link_url. |
up.* | User properties, such as up.segments, copied from the segment_update event. |
gcs is the one worth learning to read. It starts with G1, then one digit for ad storage and one for analytics storage, where 1 is granted and 0 is denied. After Accept on this site you'll see G101: analytics on, advertising off. That's the whole consent policy, written into every request.
What the hit leaves out
The lab ends with the event schema, the full list of events this site sends to Google and the parameters each one is allowed to carry. The rule behind it is short: emails, names, and form values are never parameters.
A few examples show what that looks like in practice. When the contact form or the white paper form stores a submission, generate_lead carries one parameter, form_name, set to contact or white_paper. It doesn't carry the name, email, company, or message. When you click a recommended-next card, select_content says which post you picked and why it was recommended. login and sign_up only ever report method: password.
The schema is the contract. If a value isn't on that list, it doesn't leave the page through this path.
Two paths, side by side
Go back to the Collection Lab with consent on and look at the network panel. You'll see both paths in one list. The POST /api/collect beacon is a first-party row. googletagmanager.com and google-analytics.com, or a regional host like region1.google-analytics.com, are labeled third-party Google Analytics.
They describe the same activity, but they end up in different places. The first-party record is one I can open, join, and explain row by row. The Google hit becomes part of someone else's model, and the Live page shows what that third-party view of the same visits looks like.
Neither is a black box once you can read the request. That's the point of putting both on one screen.
Labs that show this
- What dataLayer.push does
What dataLayer.push does, and how window.dataLayer becomes a Google hit. Watch the queue, the tag, and the collect request with consent on or off.
- Free Google Analytics labs
Free Google Analytics labs in this browser. See what a page collects, what a beacon sends, and how those signals personalize what you see. Open one.
- GA4 realtime active users
GA4 realtime for the last 30 minutes: users, events, key events, pages, cities, countries, and devices. Google's third-party view of the same visits.
Recommended next
Why these picksReading path transitions…