[{"data":1,"prerenderedAt":283},["ShallowReactive",2],{"rule-tag-datalayer-race":3},{"id":4,"title":5,"body":6,"breadcrumb":247,"coderail":254,"dateModified":272,"datePublished":272,"description":273,"extension":274,"meta":275,"navigation":276,"next":272,"path":277,"prev":272,"schemaType":278,"seo":279,"stem":280,"wide":281,"__hash__":282},"docs\u002Frules\u002Ftag-datalayer-race.md","dataLayer.push race condition",{"type":7,"value":8,"toc":238},"minimark",[9,16,54,59,78,82,85,89,115,119,148,152,210,214],[10,11,12],"p",{},[13,14,15],"strong",{},"Summary",[17,18,19,30,36,42,48],"ul",{},[20,21,22,25,26],"li",{},[13,23,24],{},"rule_id"," — ",[27,28,29],"code",{},"tag-datalayer-race",[20,31,32,35],{},[13,33,34],{},"purpose"," — Detect Custom HTML tags that push to the dataLayer on the same trigger with no firing priority set",[20,37,38,41],{},[13,39,40],{},"effect"," — Execution order is undefined; tags depending on each other's dataLayer entries may read stale or missing data",[20,43,44,47],{},[13,45,46],{},"layer"," — container",[20,49,50,53],{},[13,51,52],{},"reversibility"," — non-destructive",[55,56,58],"h2",{"id":57},"what-fires-this","What fires this",[10,60,61,62,65,66,69,70,73,74,77],{},"The rule collects all active Custom HTML tags where ",[27,63,64],{},"codeAnalysis.hasDataLayerPush"," is true. Tags that install event listeners are skipped — their ",[27,67,68],{},"dataLayer.push"," runs inside a callback, not synchronously at tag fire, so sibling-ordering is not the issue. The remaining tags are grouped by ",[27,71,72],{},"firingTriggerIds",". Any trigger where two or more tags in that group have no ",[27,75,76],{},"priority"," value set is flagged as a race. Paused tags are excluded.",[55,79,81],{"id":80},"why-it-matters","Why it matters",[10,83,84],{},"GTM does not guarantee execution order when multiple tags share a trigger. If Tag A pushes user context and Tag B reads that context to populate an analytics event, Tag B may execute first — sending the event with empty or stale fields. The failure is silent: both tags show a green tick in GTM Preview, but the downstream analytics row is missing data. GTM's tag firing priority field (higher numbers fire first) exists to fix this, but it requires explicit configuration.",[55,86,88],{"id":87},"example","Before \u002F after",[90,91,92,106],"compare",{},[93,94,96],"compare-col",{"label":95},"Before — flagged",[97,98,104],"pre",{"className":99,"code":101,"language":102,"meta":103},[100],"language-text","Trigger: \"All Pages\"\n  └── Tag A — \"DL - Set User Context\"   priority: (none)\n  └── Tag B — \"DL - Enrich Event Data\"  priority: (none)\n\nTag B may read user context before Tag A has pushed it.\n","text","",[27,105,101],{"__ignoreMap":103},[93,107,109],{"label":108},"After — fixed",[97,110,113],{"className":111,"code":112,"language":102,"meta":103},[100],"Trigger: \"All Pages\"\n  └── Tag A — \"DL - Set User Context\"   priority: 10\n  └── Tag B — \"DL - Enrich Event Data\"  priority: 0\n\nTag A always fires first; Tag B reads a populated dataLayer.\n",[27,114,112],{"__ignoreMap":103},[55,116,118],{"id":117},"remediation","Remediation",[120,121,122,125,128,131,142,145],"ol",{},[20,123,124],{},"Review the flagged trigger groups in the finding — each group lists the tags sharing a trigger.",[20,126,127],{},"Determine which tag must push first. A tag that writes context others read should fire earlier.",[20,129,130],{},"Open each tag in GTM and go to Advanced Settings → Tag Firing Priority.",[20,132,133,134,137,138,141],{},"Assign a higher priority number to the tag that must fire first (e.g., ",[27,135,136],{},"10","). Leave dependent tags at ",[27,139,140],{},"0",".",[20,143,144],{},"For tags whose pushes are genuinely independent, confirm they do not read each other's keys. No priority change is needed; add a comment in the tag notes documenting this.",[20,146,147],{},"Verify order in GTM Preview by checking the Summary panel tag sequence.",[55,149,151],{"id":150},"metadata","Metadata",[153,154,157,158,163,157,167,171,157,174,178,157,181,184,157,187,191,157,194,198,157,204,207],"dl",{"className":155},[156],"spec-list","\n  ",[159,160,162],"dt",{"id":161},"severity","Severity",[164,165,166],"dd",{},"medium",[159,168,170],{"id":169},"tier","Tier",[164,172,173],{},"optimization",[159,175,177],{"id":176},"category","Category",[164,179,180],{},"quality",[159,182,183],{"id":46},"Layer",[164,185,186],{},"container",[159,188,190],{"id":189},"version","Version",[164,192,193],{},"1",[159,195,197],{"id":196},"effort","Effort",[164,199,200,203],{},[27,201,202],{},"15min"," (about 15 minutes)",[159,205,206],{"id":52},"Reversibility",[164,208,209],{},"non-destructive",[55,211,213],{"id":212},"see-also","See also",[17,215,216,224,231],{},[20,217,218,223],{},[219,220,222],"a",{"href":221},"\u002Fcategories\u002Fquality\u002F","Quality rules"," — other rules in this category",[20,225,226,230],{},[219,227,229],{"href":228},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,232,233,237],{},[219,234,236],{"href":235},"\u002Frules\u002F","Rules catalog"," — browse all rules",{"title":103,"searchDepth":239,"depth":239,"links":240},2,[241,242,243,244,245,246],{"id":57,"depth":239,"text":58},{"id":80,"depth":239,"text":81},{"id":87,"depth":239,"text":88},{"id":117,"depth":239,"text":118},{"id":150,"depth":239,"text":151},{"id":212,"depth":239,"text":213},[248,251,253],{"label":249,"href":250},"API Reference","\u002F",{"label":252,"href":235},"Rules",{"label":29},{"cards":255,"onpage":266},[256],{"title":257,"tabs":258},"Evaluate",[259,263],{"label":260,"language":261,"code":262},"cURL","bash","curl https:\u002F\u002Fdeveloper.tagmanifest.com\u002Fv1\u002Fevaluate-rule \\\n  -H \"Authorization: Bearer $TM_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"rule_id\":\"tag-datalayer-race\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":264,"language":102,"code":265},"MCP","User: Run tag-datalayer-race on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"tag-datalayer-race\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[267,268,269,270,271],{"id":57,"label":58},{"id":80,"label":81},{"id":87,"label":88},{"id":117,"label":118},{"id":150,"label":151},null,"Multiple Custom HTML tags push to dataLayer on the same trigger without priority ordering, creating timing-dependent behavior.","md",{},true,"\u002Frules\u002Ftag-datalayer-race","TechArticle",{"title":5,"description":273},"rules\u002Ftag-datalayer-race",false,"XbUrzM_lFKg4IE_KLfQvMmJlKw7c1HI2HfK_PhM_Tko",1796069484301]