[{"data":1,"prerenderedAt":384},["ShallowReactive",2],{"rule-ga4-custom-html-gtag":3},{"id":4,"title":5,"body":6,"breadcrumb":348,"coderail":355,"dateModified":373,"datePublished":373,"description":374,"extension":375,"meta":376,"navigation":377,"next":373,"path":378,"prev":373,"schemaType":379,"seo":380,"stem":381,"wide":382,"__hash__":383},"docs\u002Frules\u002Fga4-custom-html-gtag.md","Custom HTML using gtag() instead of native",{"type":7,"value":8,"toc":340},"minimark",[9,16,58,63,88,92,105,109,212,216,246,250,308,312,336],[10,11,12],"p",{},[13,14,15],"strong",{},"Summary",[17,18,19,30,40,46,52],"ul",{},[20,21,22,25,26],"li",{},[13,23,24],{},"rule_id"," — ",[27,28,29],"code",{},"ga4-custom-html-gtag",[20,31,32,35,36,39],{},[13,33,34],{},"purpose"," — Detect Custom HTML tags calling ",[27,37,38],{},"gtag()"," instead of native GA4 event tags in GTM (Google Tag Manager)",[20,41,42,45],{},[13,43,44],{},"effect"," — Container bypasses GTM's consent framework and loses built-in debugging support",[20,47,48,51],{},[13,49,50],{},"layer"," — container",[20,53,54,57],{},[13,55,56],{},"reversibility"," — non-destructive",[59,60,62],"h2",{"id":61},"what-fires-this","What fires this",[10,64,65,66,69,70,72,73,76,77,80,81,84,85,87],{},"The rule inspects all active Custom HTML tags for any ",[27,67,68],{},"gtag("," call in the tag code. A tag is flagged when at least one ",[27,71,38],{}," call is not an Ads conversion or Floodlight call. The rule excludes calls matching ",[27,74,75],{},"gtag('event','conversion',...)"," with ",[27,78,79],{},"send_to: 'AW-'"," or ",[27,82,83],{},"send_to: 'DC-'"," — those are Google Ads Conversion Tracking and Floodlight, which have their own native GTM templates. The rule is conservative: if a tag contains any non-Ads ",[27,86,38],{}," call alongside conversion calls, the tag is still flagged. Paused tags are excluded.",[59,89,91],{"id":90},"why-it-matters","Why it matters",[10,93,94,95,97,98,101,102,104],{},"Native GA4 Event tags in GTM connect directly to GTM's consent state model. Custom HTML ",[27,96,38],{}," calls do not. When consent is withdrawn, a native tag stops firing automatically; a Custom HTML tag continues unless the developer adds manual consent checks. Custom HTML tags also load the ",[27,99,100],{},"gtag.js"," script independently, which can conflict with an existing Global Site Tag and create duplicate hits. Native tags surface in GTM's Tag Assistant and Preview mode with parameter-level detail. ",[27,103,38],{}," in Custom HTML appears as an opaque block.",[59,106,108],{"id":107},"example","Before \u002F after",[110,111,112,201],"compare",{},[113,114,116],"compare-col",{"label":115},"Before — flagged",[117,118,123],"pre",{"className":119,"code":120,"language":121,"meta":122,"style":122},"language-html shiki shiki-themes github-light github-dark","\u003Cscript>\n  gtag('event', 'purchase', {\n    transaction_id: order.id,\n    value: order.total,\n    currency: 'USD'\n  });\n\u003C\u002Fscript>\n","html","",[27,124,125,141,164,170,176,185,191],{"__ignoreMap":122},[126,127,130,134,138],"span",{"class":128,"line":129},"line",1,[126,131,133],{"class":132},"sVt8B","\u003C",[126,135,137],{"class":136},"s9eBZ","script",[126,139,140],{"class":132},">\n",[126,142,144,148,151,155,158,161],{"class":128,"line":143},2,[126,145,147],{"class":146},"sScJk","  gtag",[126,149,150],{"class":132},"(",[126,152,154],{"class":153},"sZZnC","'event'",[126,156,157],{"class":132},", ",[126,159,160],{"class":153},"'purchase'",[126,162,163],{"class":132},", {\n",[126,165,167],{"class":128,"line":166},3,[126,168,169],{"class":132},"    transaction_id: order.id,\n",[126,171,173],{"class":128,"line":172},4,[126,174,175],{"class":132},"    value: order.total,\n",[126,177,179,182],{"class":128,"line":178},5,[126,180,181],{"class":132},"    currency: ",[126,183,184],{"class":153},"'USD'\n",[126,186,188],{"class":128,"line":187},6,[126,189,190],{"class":132},"  });\n",[126,192,194,197,199],{"class":128,"line":193},7,[126,195,196],{"class":132},"\u003C\u002F",[126,198,137],{"class":136},[126,200,140],{"class":132},[113,202,204],{"label":203},"After — fixed",[117,205,210],{"className":206,"code":208,"language":209,"meta":122},[207],"language-text","GTM tag type: GA4 Event\nTag name: GA4 — Purchase\nConfiguration tag: [GA4 Config tag]\nEvent name: purchase\nEvent parameters:\n  transaction_id → {{DL - order.id}}\n  value          → {{DL - order.total}}\n  currency       → USD\nConsent settings: inherited from GA4 Config tag\n","text",[27,211,208],{"__ignoreMap":122},[59,213,215],{"id":214},"remediation","Remediation",[217,218,219,222,228,231,237,240,243],"ol",{},[20,220,221],{},"Open GTM and find each flagged Custom HTML tag.",[20,223,224,225,227],{},"Identify which GA4 event the ",[27,226,38],{}," call is sending.",[20,229,230],{},"Create a new GA4 Event tag of the same name, linked to your existing GA4 Configuration tag.",[20,232,233,234,236],{},"Map each parameter from the ",[27,235,38],{}," call to GTM variables in the new tag.",[20,238,239],{},"Set the same firing triggers as the Custom HTML tag.",[20,241,242],{},"Test the new tag in GTM Preview mode and confirm hits appear in GA4 DebugView.",[20,244,245],{},"Pause or delete the Custom HTML tag after confirming parity.",[59,247,249],{"id":248},"metadata","Metadata",[251,252,255,256,261,255,265,269,255,272,276,255,279,282,255,285,289,255,292,296,255,302,305],"dl",{"className":253},[254],"spec-list","\n  ",[257,258,260],"dt",{"id":259},"severity","Severity",[262,263,264],"dd",{},"medium",[257,266,268],{"id":267},"tier","Tier",[262,270,271],{},"optimization",[257,273,275],{"id":274},"category","Category",[262,277,278],{},"ga4",[257,280,281],{"id":50},"Layer",[262,283,284],{},"container",[257,286,288],{"id":287},"version","Version",[262,290,291],{},"1",[257,293,295],{"id":294},"effort","Effort",[262,297,298,301],{},[27,299,300],{},"2hr"," (about 2 hours)",[257,303,304],{"id":56},"Reversibility",[262,306,307],{},"non-destructive",[59,309,311],{"id":310},"see-also","See also",[17,313,314,322,329],{},[20,315,316,321],{},[317,318,320],"a",{"href":319},"\u002Fcategories\u002Fga4\u002F","GA4 rules"," — other rules in this category",[20,323,324,328],{},[317,325,327],{"href":326},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,330,331,335],{},[317,332,334],{"href":333},"\u002Frules\u002F","Rules catalog"," — browse all rules",[337,338,339],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":122,"searchDepth":143,"depth":143,"links":341},[342,343,344,345,346,347],{"id":61,"depth":143,"text":62},{"id":90,"depth":143,"text":91},{"id":107,"depth":143,"text":108},{"id":214,"depth":143,"text":215},{"id":248,"depth":143,"text":249},{"id":310,"depth":143,"text":311},[349,352,354],{"label":350,"href":351},"API Reference","\u002F",{"label":353,"href":333},"Rules",{"label":29},{"cards":356,"onpage":367},[357],{"title":358,"tabs":359},"Evaluate",[360,364],{"label":361,"language":362,"code":363},"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-custom-html-gtag\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":365,"language":209,"code":366},"MCP","User: Run ga4-custom-html-gtag on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"ga4-custom-html-gtag\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[368,369,370,371,372],{"id":61,"label":62},{"id":90,"label":91},{"id":107,"label":108},{"id":214,"label":215},{"id":248,"label":249},null,"Custom HTML contains gtag() calls instead of using native GA4 event tags, losing consent integration and debugging.","md",{},true,"\u002Frules\u002Fga4-custom-html-gtag","TechArticle",{"title":5,"description":374},"rules\u002Fga4-custom-html-gtag",false,"hHBShh6oe7eXh-2UK5MIJ4fNVwwAGP0iX8jG9wl-FbU",1796069483602]