Skip to main content
TagManifest /Docs Dashboard

Orphaned variables (not used by any tag or trigger)

Variables not referenced by any tag or trigger. Special public-scan handling: when ALL variables look orphaned from a public scan, emits a different finding suggesting JSON upload.

On this page 6

Summary

  • rule_id — orphaned-variables
  • purpose — Detect variables not referenced by any tag or trigger in the container
  • effect — Orphaned variables add noise to the variable list and inflate published container size
  • layer — container
  • reversibility — non-destructive

What fires this

The rule filters data.variables for entries where both referencedByTags.length === 0 and referencedByTriggers.length === 0. A special case applies to public-endpoint scans: if all variables appear unreferenced and the container has more than five variables total, the rule assumes the public scan lacks sufficient data to trace usage. It emits a softer finding recommending a JSON export upload rather than treating every variable as orphaned. For JSON container exports, reference detection is accurate.

Why it matters

Variables accumulate when tags or trigger conditions are deleted without removing the variables they depended on. Over time, the variable list fills with entries that serve no active purpose. In containers using prefix-based naming conventions, orphaned variables with matching prefixes can mislead reviewers about which platforms or features are currently tracked. Variables also contribute to GTM's published container payload — removing unused ones keeps the container leaner and the variable list legible.

Before / after

Variable DLV - userId exists in the container but no tag references it in its fields, and no trigger condition uses it. It was created for a tag deleted six months ago and never cleaned up.

Variable deleted. Container variable list reflects only variables in active use. If the variable may return, add a description field documenting the intended purpose before archiving.

Remediation

  1. Review the orphaned variable list in the finding output.
  2. For each variable, check for indirect references: Custom JavaScript variables that call it by name, or Additional Consent configurations that reference it as a string.
  3. Delete variables confirmed to be unused.
  4. For variables kept for future use, add a description to the variable configuration explaining its intended purpose.
  5. Publish the updated container.

Metadata

Severity
medium
Tier
info
Category
organization
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":"orphaned-variables","url":"https://example.com"}'