WebmasterID logoWebmasterID
Event tracking

gtag.js vs Google Tag Manager events

There are two common ways to send events to GA4: gtag.js, where you call the gtag() function directly in code, and Google Tag Manager (GTM), where tags fire based on triggers reading a data layer. They reach the same destination but differ in who controls firing and how events are defined. Choosing between them is about workflow and governance — not about privacy, which applies equally to both.

Verified against primary sources

What this means

With gtag.js, developers call gtag('event', ...) directly in the page code; the logic for what fires lives in the codebase. With Google Tag Manager, a container script loads and fires tags based on triggers that evaluate a data layer the site pushes to; marketers can add or change tags in the GTM UI without code deploys. Both ultimately send the same GA4 events to the same property.

Trade-offs in control and governance

gtag.js keeps tagging in code: version-controlled and developer-owned, but every change needs a deploy. GTM moves tag management into a UI: faster iteration and non-developer access, at the cost of a layer that can fire third-party tags and needs governance to stay clean. Neither is inherently 'better' — they suit different teams. What does not change between them is privacy: consent, data minimisation, and no-PII rules bind both paths identically.

How it appears in analytics and logs

An event you cannot find in code may be defined as a GTM tag firing on a data-layer trigger; one not in GTM may be a direct gtag() call. Know which path your events take.

Diagnostic use case

Decide whether to send events directly with gtag.js or manage them in Tag Manager, based on who needs to control tagging and how it is governed.

What WebmasterID can help detect

WebmasterID's first-party tracker is a third path: a lightweight script that emits events directly, without a tag manager or third-party container.

Common mistakes

Privacy and accuracy notes

gtag and GTM are delivery mechanisms; neither makes data collection lawful or removes consent duties. The same data-minimisation rules apply to both. This is educational, not legal advice.

Related pages

Sources and verification notes

Last reviewed 2026-06-24. Facts are checked against primary/official sources where available; uncertain specifics are marked “Data not yet verified” rather than guessed.