Skip to main content
TagManifest /Docs Dashboard

Measurement ID hardcoded

GA4 measurement ID hardcoded as a literal value instead of using a GTM variable for reuse and easy updates.

On this page 6

Summary

  • rule_id — ga4-measurement-id-hardcoded
  • purpose — Detect GA4 tags where the measurement ID is a hardcoded literal instead of a GTM variable
  • effect — Multiple IDs duplicated across tags; any ID change requires editing every tag individually
  • layer — container
  • reversibility — non-destructive

What fires this

The rule calls getGA4Tags() to collect all GA4 configuration and event tags, then filters for tags where t.ga4.measurementId is a literal string matching the G-, AW-, or DC- prefix and does not start with {{ (a GTM variable reference). It counts the distinct measurement IDs across those tags. The rule fires only when two or more unique IDs are hardcoded — a single-property container with one repeated literal does not trigger. Paused tags are excluded.

Why it matters

When measurement IDs are hardcoded across multiple tags, any ID change requires editing every tag individually. In containers that send to both GA4 and Google Ads (G- and AW- prefixes), this multiplies the maintenance surface. A GTM Constant variable centralises the value — update it once and every tag picks up the change. It also makes environment switching (staging vs. production IDs) a single variable swap rather than a container-wide find-and-replace.

Before / after

Tag: "GA4 - Page View"
  Measurement ID: G-ABC123456   ← literal

Tag: "GA4 - Purchase"
  Measurement ID: G-ABC123456   ← literal (duplicate)

Tag: "Google Ads - Conversion"
  Measurement ID: AW-987654321  ← literal

Two unique IDs hardcoded → rule fires
Variable: "GA4 Measurement ID"  → G-ABC123456
Variable: "Google Ads ID"       → AW-987654321

Tag: "GA4 - Page View"
  Measurement ID: {{GA4 Measurement ID}}

Tag: "GA4 - Purchase"
  Measurement ID: {{GA4 Measurement ID}}

Tag: "Google Ads - Conversion"
  Measurement ID: {{Google Ads ID}}

Remediation

  1. Review the finding detail to identify all unique measurement IDs in the container.
  2. In GTM Variables, create a Constant variable for each unique ID (e.g., GA4 Measurement ID, Google Ads ID).
  3. Set each variable's value to the corresponding literal ID string.
  4. Open each flagged tag and replace the hardcoded ID field with the matching variable reference.
  5. Preview the container and confirm each tag resolves the correct ID in Tag Assistant.
  6. Publish the container.

Metadata

Severity
low
Tier
info
Category
ga4
Layer
container
Version
1
Effort
15min (about 15 minutes)
Reversibility
non-destructive

See also

Examples

Evaluate
curl https://developer.tagmanifest.com/v1/evaluate-rule \
  -H "Authorization: Bearer $TM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rule_id":"ga4-measurement-id-hardcoded","url":"https://example.com"}'