[{"data":1,"prerenderedAt":490},["ShallowReactive",2],{"rule-ecommerce-event-wrong-trigger":3},{"id":4,"title":5,"body":6,"breadcrumb":453,"coderail":460,"dateModified":479,"datePublished":479,"description":480,"extension":481,"meta":482,"navigation":483,"next":479,"path":484,"prev":479,"schemaType":485,"seo":486,"stem":487,"wide":488,"__hash__":489},"docs\u002Frules\u002Fecommerce-event-wrong-trigger.md","Ecommerce events on page-load triggers",{"type":7,"value":8,"toc":445},"minimark",[9,16,54,59,129,133,139,143,323,327,351,355,413,417,441],[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",{},"ecommerce-event-wrong-trigger",[20,31,32,35],{},[13,33,34],{},"purpose"," — Detect GA4 ecommerce action tags firing on page-load or link-click triggers instead of Custom Event triggers",[20,37,38,41],{},[13,39,40],{},"effect"," — Every page view sends a spurious ecommerce event, inflating funnel counts",[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,73,77,73,80,73,83,73,86,73,89,92,93,96,97,100,101,73,104,73,107,73,110,92,113,116,117,120,121,124,125,128],{},"The rule calls ",[27,63,64],{},"getGA4EventTags()"," and filters for tags whose ",[27,67,68],{},"ga4.eventName"," matches one of eight action events: ",[27,71,72],{},"add_to_cart",", ",[27,75,76],{},"remove_from_cart",[27,78,79],{},"view_cart",[27,81,82],{},"begin_checkout",[27,84,85],{},"add_shipping_info",[27,87,88],{},"add_payment_info",[27,90,91],{},"select_item",", or ",[27,94,95],{},"refund",". For each matching tag, it checks whether any entry in ",[27,98,99],{},"firingTriggerIds"," maps to a trigger with type ",[27,102,103],{},"PAGEVIEW",[27,105,106],{},"DOM_READY",[27,108,109],{},"WINDOW_LOADED",[27,111,112],{},"LINK_CLICK",[27,114,115],{},"JUST_LINKS",", or is one of GTM's built-in page-load triggers (All Pages, Initialization, Consent Initialization). Tags meeting that condition are flagged. The ",[27,118,119],{},"purchase"," event is excluded — it is covered by ",[27,122,123],{},"ga4-purchase-wrong-trigger",". The ",[27,126,127],{},"page_view"," event is excluded because it legitimately fires on page load.",[55,130,132],{"id":131},"why-it-matters","Why it matters",[10,134,135,136,138],{},"Page-load triggers fire on every page load, whether or not the user took any action. An ",[27,137,72],{}," tag on a PAGEVIEW trigger sends that event to GA4 on every page view. Add-to-cart rates appear to be 100%, checkout abandonment becomes unmeasurable, and revenue attribution downstream is unreliable. Ecommerce events should fire when the dataLayer receives the corresponding push — that push happens only when the user actually performs the action. Custom Event triggers wired to dataLayer events are the correct shape.",[55,140,142],{"id":141},"example","Before \u002F after",[144,145,146,246],"compare",{},[147,148,150],"compare-col",{"label":149},"Before — flagged",[151,152,157],"pre",{"className":153,"code":154,"language":155,"meta":156,"style":156},"language-json shiki shiki-themes github-light github-dark","{\n  \"tag\": \"GA4 - add_to_cart\",\n  \"ga4EventName\": \"add_to_cart\",\n  \"firingTriggers\": [\n    { \"name\": \"All Pages\", \"type\": \"PAGEVIEW\" }\n  ]\n}\n","json","",[27,158,159,168,185,198,207,234,240],{"__ignoreMap":156},[160,161,164],"span",{"class":162,"line":163},"line",1,[160,165,167],{"class":166},"sVt8B","{\n",[160,169,171,175,178,182],{"class":162,"line":170},2,[160,172,174],{"class":173},"sj4cs","  \"tag\"",[160,176,177],{"class":166},": ",[160,179,181],{"class":180},"sZZnC","\"GA4 - add_to_cart\"",[160,183,184],{"class":166},",\n",[160,186,188,191,193,196],{"class":162,"line":187},3,[160,189,190],{"class":173},"  \"ga4EventName\"",[160,192,177],{"class":166},[160,194,195],{"class":180},"\"add_to_cart\"",[160,197,184],{"class":166},[160,199,201,204],{"class":162,"line":200},4,[160,202,203],{"class":173},"  \"firingTriggers\"",[160,205,206],{"class":166},": [\n",[160,208,210,213,216,218,221,223,226,228,231],{"class":162,"line":209},5,[160,211,212],{"class":166},"    { ",[160,214,215],{"class":173},"\"name\"",[160,217,177],{"class":166},[160,219,220],{"class":180},"\"All Pages\"",[160,222,73],{"class":166},[160,224,225],{"class":173},"\"type\"",[160,227,177],{"class":166},[160,229,230],{"class":180},"\"PAGEVIEW\"",[160,232,233],{"class":166}," }\n",[160,235,237],{"class":162,"line":236},6,[160,238,239],{"class":166},"  ]\n",[160,241,243],{"class":162,"line":242},7,[160,244,245],{"class":166},"}\n",[147,247,249],{"label":248},"After — fixed",[151,250,252],{"className":153,"code":251,"language":155,"meta":156,"style":156},"{\n  \"tag\": \"GA4 - add_to_cart\",\n  \"ga4EventName\": \"add_to_cart\",\n  \"firingTriggers\": [\n    { \"name\": \"CE - add_to_cart\", \"type\": \"CUSTOM_EVENT\", \"eventName\": \"add_to_cart\" }\n  ]\n}\n",[27,253,254,258,268,278,284,315,319],{"__ignoreMap":156},[160,255,256],{"class":162,"line":163},[160,257,167],{"class":166},[160,259,260,262,264,266],{"class":162,"line":170},[160,261,174],{"class":173},[160,263,177],{"class":166},[160,265,181],{"class":180},[160,267,184],{"class":166},[160,269,270,272,274,276],{"class":162,"line":187},[160,271,190],{"class":173},[160,273,177],{"class":166},[160,275,195],{"class":180},[160,277,184],{"class":166},[160,279,280,282],{"class":162,"line":200},[160,281,203],{"class":173},[160,283,206],{"class":166},[160,285,286,288,290,292,295,297,299,301,304,306,309,311,313],{"class":162,"line":209},[160,287,212],{"class":166},[160,289,215],{"class":173},[160,291,177],{"class":166},[160,293,294],{"class":180},"\"CE - add_to_cart\"",[160,296,73],{"class":166},[160,298,225],{"class":173},[160,300,177],{"class":166},[160,302,303],{"class":180},"\"CUSTOM_EVENT\"",[160,305,73],{"class":166},[160,307,308],{"class":173},"\"eventName\"",[160,310,177],{"class":166},[160,312,195],{"class":180},[160,314,233],{"class":166},[160,316,317],{"class":162,"line":236},[160,318,239],{"class":166},[160,320,321],{"class":162,"line":242},[160,322,245],{"class":166},[55,324,326],{"id":325},"remediation","Remediation",[328,329,330,333,339,342,345,348],"ol",{},[20,331,332],{},"Open each flagged tag in GTM and note the current trigger assignment.",[20,334,335,336,338],{},"Identify the dataLayer event name the site pushes when the action occurs (e.g., ",[27,337,72],{}," on button click).",[20,340,341],{},"Create a Custom Event trigger with the Event Name matching that dataLayer event.",[20,343,344],{},"Remove the page-load trigger from the tag and assign the new Custom Event trigger.",[20,346,347],{},"Confirm with the development team that the dataLayer push fires at the correct moment — on the user action, not on page load.",[20,349,350],{},"Test in GTM Preview mode: perform the action and verify the event fires exactly once per action.",[55,352,354],{"id":353},"metadata","Metadata",[356,357,360,361,366,360,370,374,360,377,381,360,384,387,360,390,394,360,397,401,360,407,410],"dl",{"className":358},[359],"spec-list","\n  ",[362,363,365],"dt",{"id":364},"severity","Severity",[367,368,369],"dd",{},"high",[362,371,373],{"id":372},"tier","Tier",[367,375,376],{},"optimization",[362,378,380],{"id":379},"category","Category",[367,382,383],{},"ecommerce",[362,385,386],{"id":46},"Layer",[367,388,389],{},"container",[362,391,393],{"id":392},"version","Version",[367,395,396],{},"1",[362,398,400],{"id":399},"effort","Effort",[367,402,403,406],{},[27,404,405],{},"2hr"," (about 2 hours)",[362,408,409],{"id":52},"Reversibility",[367,411,412],{},"non-destructive",[55,414,416],{"id":415},"see-also","See also",[17,418,419,427,434],{},[20,420,421,426],{},[422,423,425],"a",{"href":424},"\u002Fcategories\u002Fecommerce\u002F","Ecommerce rules"," — other rules in this category",[20,428,429,433],{},[422,430,432],{"href":431},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,435,436,440],{},[422,437,439],{"href":438},"\u002Frules\u002F","Rules catalog"," — browse all 92 rules",[442,443,444],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}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":156,"searchDepth":170,"depth":170,"links":446},[447,448,449,450,451,452],{"id":57,"depth":170,"text":58},{"id":131,"depth":170,"text":132},{"id":141,"depth":170,"text":142},{"id":325,"depth":170,"text":326},{"id":353,"depth":170,"text":354},{"id":415,"depth":170,"text":416},[454,457,459],{"label":455,"href":456},"API Reference","\u002F",{"label":458,"href":438},"Rules",{"label":29},{"cards":461,"onpage":473},[462],{"title":463,"tabs":464},"Evaluate",[465,469],{"label":466,"language":467,"code":468},"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\":\"ecommerce-event-wrong-trigger\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":470,"language":471,"code":472},"MCP","text","User: Run ecommerce-event-wrong-trigger on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"ecommerce-event-wrong-trigger\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[474,475,476,477,478],{"id":57,"label":58},{"id":131,"label":132},{"id":141,"label":142},{"id":325,"label":326},{"id":353,"label":354},null,"Detects GA4 ecommerce action event tags (add_to_cart, begin_checkout, etc.) firing on page-load or link-click triggers instead of Custom Event triggers.","md",{},true,"\u002Frules\u002Fecommerce-event-wrong-trigger","TechArticle",{"title":5,"description":480},"rules\u002Fecommerce-event-wrong-trigger",false,"J2DoQvTSSTkasMCPxGG8rCPJlQ2tiUcZKqRogC-a2Ik",1796069483527]