Variable referencing 5+ other variables
A variable references 5 or more other variables, creating a single point of failure in the variable chain.
Summary
- rule_id —
variable-high-fanout - purpose — Detect variables that depend on 5 or more other variables, creating fragile dependency chains
- effect — Any single broken dependency silently fails the entire computed value
- layer — container
- reversibility — non-destructive
What fires this
The rule JSON-stringifies each variable's parameters object and scans it for {{variable_name}} references using a global regex. Variables with 5 or more distinct references are flagged. Google Ads Enhanced Conversions (awec) and User Data (awud) variable types are excluded — those types structurally reference 5–7 field macros by platform design, not by accident. All other variable types are in scope.
Why it matters
A variable referencing 5+ others forms a dependency chain with no redundancy. If any referenced variable is deleted, renamed, or returns undefined — due to a dataLayer change, trigger timing, or missing page context — the entire computed value fails. The failure is often silent: GTM Preview may show the variable evaluating on some pages but not others. Every tag that consumes the high-fanout variable inherits the same fragility. Splitting the logic or adding ?? fallbacks makes failures isolated and debuggable.
Before / after
One Custom JavaScript variable reads {{User ID}}, {{Session ID}}, {{Page Category}}, {{Product ID}}, and {{Experiment Variant}} to build a composite event payload. Deleting or renaming any one of those variables breaks the tag silently.
An intermediate variable handles user context ({{User ID}} + {{Session ID}}), another handles page context ({{Page Category}} + {{Product ID}}), and the composite variable references those two intermediates plus {{Experiment Variant}}. Each intermediate has ?? null fallbacks, so a missing value surfaces as null rather than cascading to undefined.
Remediation
- Open each flagged variable and list every
{{reference}}it contains. - Determine whether all references are necessary for the computed output.
- Group logically related references into intermediate Custom JavaScript variables.
- Add
??(nullish coalescing) or|| defaultValueguards for each reference that may be absent. - Verify that dependent tags receive a usable fallback when one input is missing.
- Test on pages where individual dependencies are known not to populate.
Metadata
- Severity
- medium
- Tier
- optimization
- Category
- quality
- Layer
- container
- Version
- 1
- Effort
strategic(no fixed time; needs a plan)- Reversibility
- non-destructive
See also
- Quality rules — other rules in this category
- Health score — how this rule contributes to the score
- Rules catalog — browse all rules
Examples
curl https://developer.tagmanifest.com/v1/evaluate-rule \
-H "Authorization: Bearer $TM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rule_id":"variable-high-fanout","url":"https://example.com"}'
User: Run variable-high-fanout on https://example.com
# Tool call
{
"tool": "evaluate_rule",
"arguments": {
"rule_id": "variable-high-fanout",
"url": "https://example.com"
}
}