[{"data":1,"prerenderedAt":296},["ShallowReactive",2],{"rule-ga4-measurement-id-hardcoded":3},{"id":4,"title":5,"body":6,"breadcrumb":260,"coderail":267,"dateModified":285,"datePublished":285,"description":286,"extension":287,"meta":288,"navigation":289,"next":285,"path":290,"prev":285,"schemaType":291,"seo":292,"stem":293,"wide":294,"__hash__":295},"docs\u002Frules\u002Fga4-measurement-id-hardcoded.md","Measurement ID hardcoded",{"type":7,"value":8,"toc":251},"minimark",[9,16,54,59,86,90,99,103,129,133,161,165,223,227],[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",{},"ga4-measurement-id-hardcoded",[20,31,32,35],{},[13,33,34],{},"purpose"," — Detect GA4 tags where the measurement ID is a hardcoded literal instead of a GTM variable",[20,37,38,41],{},[13,39,40],{},"effect"," — Multiple IDs duplicated across tags; any ID change requires editing every tag individually",[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,78,81,82,85],{},"The rule calls ",[27,63,64],{},"getGA4Tags()"," to collect all GA4 configuration and event tags, then filters for tags where ",[27,67,68],{},"t.ga4.measurementId"," is a literal string matching the ",[27,71,72],{},"G-",", ",[27,75,76],{},"AW-",", or ",[27,79,80],{},"DC-"," prefix and does not start with ",[27,83,84],{},"{{"," (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.",[55,87,89],{"id":88},"why-it-matters","Why it matters",[10,91,92,93,95,96,98],{},"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 (",[27,94,72],{}," and ",[27,97,76],{}," 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.",[55,100,102],{"id":101},"example","Before \u002F after",[104,105,106,120],"compare",{},[107,108,110],"compare-col",{"label":109},"Before — flagged",[111,112,118],"pre",{"className":113,"code":115,"language":116,"meta":117},[114],"language-text","Tag: \"GA4 - Page View\"\n  Measurement ID: G-ABC123456   ← literal\n\nTag: \"GA4 - Purchase\"\n  Measurement ID: G-ABC123456   ← literal (duplicate)\n\nTag: \"Google Ads - Conversion\"\n  Measurement ID: AW-987654321  ← literal\n\nTwo unique IDs hardcoded → rule fires\n","text","",[27,119,115],{"__ignoreMap":117},[107,121,123],{"label":122},"After — fixed",[111,124,127],{"className":125,"code":126,"language":116,"meta":117},[114],"Variable: \"GA4 Measurement ID\"  → G-ABC123456\nVariable: \"Google Ads ID\"       → AW-987654321\n\nTag: \"GA4 - Page View\"\n  Measurement ID: {{GA4 Measurement ID}}\n\nTag: \"GA4 - Purchase\"\n  Measurement ID: {{GA4 Measurement ID}}\n\nTag: \"Google Ads - Conversion\"\n  Measurement ID: {{Google Ads ID}}\n",[27,128,126],{"__ignoreMap":117},[55,130,132],{"id":131},"remediation","Remediation",[134,135,136,139,149,152,155,158],"ol",{},[20,137,138],{},"Review the finding detail to identify all unique measurement IDs in the container.",[20,140,141,142,73,145,148],{},"In GTM Variables, create a Constant variable for each unique ID (e.g., ",[27,143,144],{},"GA4 Measurement ID",[27,146,147],{},"Google Ads ID",").",[20,150,151],{},"Set each variable's value to the corresponding literal ID string.",[20,153,154],{},"Open each flagged tag and replace the hardcoded ID field with the matching variable reference.",[20,156,157],{},"Preview the container and confirm each tag resolves the correct ID in Tag Assistant.",[20,159,160],{},"Publish the container.",[55,162,164],{"id":163},"metadata","Metadata",[166,167,170,171,176,170,180,184,170,187,191,170,194,197,170,200,204,170,207,211,170,217,220],"dl",{"className":168},[169],"spec-list","\n  ",[172,173,175],"dt",{"id":174},"severity","Severity",[177,178,179],"dd",{},"low",[172,181,183],{"id":182},"tier","Tier",[177,185,186],{},"info",[172,188,190],{"id":189},"category","Category",[177,192,193],{},"ga4",[172,195,196],{"id":46},"Layer",[177,198,199],{},"container",[172,201,203],{"id":202},"version","Version",[177,205,206],{},"1",[172,208,210],{"id":209},"effort","Effort",[177,212,213,216],{},[27,214,215],{},"15min"," (about 15 minutes)",[172,218,219],{"id":52},"Reversibility",[177,221,222],{},"non-destructive",[55,224,226],{"id":225},"see-also","See also",[17,228,229,237,244],{},[20,230,231,236],{},[232,233,235],"a",{"href":234},"\u002Fcategories\u002Fga4\u002F","GA4 rules"," — other rules in this category",[20,238,239,243],{},[232,240,242],{"href":241},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,245,246,250],{},[232,247,249],{"href":248},"\u002Frules\u002F","Rules catalog"," — browse all rules",{"title":117,"searchDepth":252,"depth":252,"links":253},2,[254,255,256,257,258,259],{"id":57,"depth":252,"text":58},{"id":88,"depth":252,"text":89},{"id":101,"depth":252,"text":102},{"id":131,"depth":252,"text":132},{"id":163,"depth":252,"text":164},{"id":225,"depth":252,"text":226},[261,264,266],{"label":262,"href":263},"API Reference","\u002F",{"label":265,"href":248},"Rules",{"label":29},{"cards":268,"onpage":279},[269],{"title":270,"tabs":271},"Evaluate",[272,276],{"label":273,"language":274,"code":275},"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\":\"ga4-measurement-id-hardcoded\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":277,"language":116,"code":278},"MCP","User: Run ga4-measurement-id-hardcoded on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"ga4-measurement-id-hardcoded\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[280,281,282,283,284],{"id":57,"label":58},{"id":88,"label":89},{"id":101,"label":102},{"id":131,"label":132},{"id":163,"label":164},null,"GA4 measurement ID hardcoded as a literal value instead of using a GTM variable for reuse and easy updates.","md",{},true,"\u002Frules\u002Fga4-measurement-id-hardcoded","TechArticle",{"title":5,"description":286},"rules\u002Fga4-measurement-id-hardcoded",false,"sUKRLnAgUgp49Ghb5XXvHaZr4mbh6vyOVjuafkNebMQ",1796069483822]