WebmasterID logoWebmasterID
Event tracking

gtag set vs config

In the gtag.js API, set and config look similar but do different jobs. gtag('config', ...) initialises a destination (like a GA4 measurement id) and can pass configuration for it. gtag('set', ...) sets values that apply to subsequent events globally, regardless of destination. Mixing them up leads to parameters that do not attach where you expect. This page clarifies their scope.

Verified against primary sources

What this means

gtag('config', 'TARGET_ID', {...}) tells gtag.js to initialise a specific destination — for GA4, your measurement id — and the object can include settings and parameters for that configuration. gtag('set', {...}) sets field values that persist across subsequent gtag calls and apply globally, not tied to one destination. So config is about setting up a target; set is about establishing values that ride along on later events.

When to use which

Use config to initialise GA4 and pass destination-level options. Use set when you want a value attached to all later events — for instance a global parameter you want present everywhere without repeating it on each event call. Because set is sticky and global while config is per-call and per-destination, passing something to the wrong one is a common cause of 'my parameter is missing'. Keep every value non-identifying regardless of which you use.

How it appears in analytics and logs

A parameter you expected on every event but see on none often means it was passed to config (one destination/call) instead of set (global and persistent).

Diagnostic use case

Attach persistent parameters or configuration correctly by choosing gtag set (global, sticky values) versus gtag config (per-destination setup).

What WebmasterID can help detect

WebmasterID's first-party tracker avoids this footgun by keeping a small explicit event API; the gtag scope distinction is specific to Google's tag.

Common mistakes

Privacy and accuracy notes

Both commands can carry parameters; neither makes PII acceptable. Do not set personal data globally via set or per-config — keep all values non-identifying. 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.