[null,null,["上次更新時間:2024-08-21 (世界標準時間)。"],[[["\u003cp\u003eUtilize the DebugView report to confirm real-time reception of ecommerce events and their parameters within Google Analytics.\u003c/p\u003e\n"],["\u003cp\u003eEnsure proper event syntax, including commas after each parameter value, JavaScript placement after the Google tag, and correct event names and required parameters.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshoot missing events by verifying syntax, event placement, and the transaction ID; duplicate events may arise from using multiple Google tags on a page.\u003c/p\u003e\n"],["\u003cp\u003eWhen setting up ecommerce events, use the correct recommended event names to ensure proper registration within Google Analytics.\u003c/p\u003e\n"],["\u003cp\u003eRemember to check for common issues such as missing commas and incorrect event placement, which can prevent events from being collected.\u003c/p\u003e\n"]]],["To validate ecommerce events with gtag.js, use the DebugView report to confirm Analytics receives events and parameters. If events are missing, ensure commas are present after each parameter value, and events are within JavaScript after the Google tag. Verify the event syntax includes correct parentheses, brackets, and curly braces. Ensure proper event names are used and transaction IDs are unique. To avoid duplicates, use only one tagging method (gtag.js or Google Tag Manager) and add the tag to each website page.\n"],null,["# Validate your ecommerce setup (gtag.js)\n\nThis document provides an overview on how to validate that Analytics is\ncollecting ecommerce events from your website when you use gtag.js. The document\nassumes that you've read [Measure ecommerce](/analytics/devguides/collection/ga4/ecommerce?client_type=gtag).\n| **Got 3 mins?** Help us improve the Google Analytics ecommerce documentation by taking [a quick online survey](https://forms.gle/ab1ADpfw6xZEkFAC6).\n\nSee ecommerce events in real time\n---------------------------------\n\nOnce you add ecommerce events to your website and begin to trigger the events,\nuse [the DebugView report](https://support.google.com/analytics/answer/7201382) to validate that Analytics has received the ecommerce\nevents and event parameters. The DebugView report lets you see each event-level\nand item-level parameter that Analytics collects from your website.\n\nThe DebugView report continuously streams events and displays the event name\neach time an event is collected. To see the parameters associated with an event,\nclick the name of the event. If you've included an `items` array, you will see\nan additional tab for the items sent with the event.\n\nTroubleshoot missing ecommerce events\n-------------------------------------\n\nThe following describes possible reasons why you don't see an ecommerce event in\nAnalytics.\n\n### Check the commas\n\nYou must include a comma after every parameter value. Analytics ignores\necommerce events that have a parameter with a missing comma, as well as any\nother events that come after the ignored event. For example, the following event\nisn't collected: \n\n gtag(\"event\", \"refund\", {\n currency: \"USD\",\n transaction_id: \"T_12345\" // Missing a trailing comma\n value: 30.03,\n coupon: \"SUMMER_FUN\",\n shipping: 3.33,\n tax: 1.11\n });\n\n### Check the placement\n\nYou must place ecommerce events in JavaScript rather than HTML, and your events\nmust go after the Google tag rather than before the Google tag.\n\n**Good:** \n\n \u003cbody\u003e\n \u003cp\u003eHello, World!\u003c/p\u003e\n \u003cscript\u003e\n gtag(\"event\", \"\u003cevent-name\u003e\");\n \u003c/script\u003e\n \u003c/body\u003e\n\n**Good:** \n\n \u003cbody\u003e\n \u003cp\u003eHello, World!\u003c/p\u003e\n \u003cscript src=\"my_events.js\"\u003e\u003c/script\u003e\n \u003c/body\u003e\n\n**Bad:** \n\n \u003cbody\u003e\n \u003cp\u003eHello, World!\u003c/p\u003e\n gtag(\"event\", \"\u003cevent-name\u003e\");\n \u003c/body\u003e\n\n**Bad:** \n\n \u003chead\u003e\n \u003cscript\u003e\n gtag(\"event\", \"\u003cevent-name\u003e\");\n \u003c/script\u003e\n \u003c!-- the Google tag --\u003e\n \u003c/head\u003e\n\n### Check the event syntax\n\nThe following `purchase` event uses the correct syntax: \n\n gtag('event', 'purchase', {\n transaction_id: \"T_12345\",\n value: 72.05,\n currency: \"USD\",\n items: [\n {\n item_id: \"SKU_12345\",\n item_name: \"Stan and Friends Tee\",\n },\n {\n item_id: \"SKU_12346\",\n item_name: \"Google Grey Women's Tee\",\n }]\n });\n\nCheck that the separators in your event are correctly placed:\n\n- Parentheses after `gtag` and before the closing semicolon\n- Curly brackets before and after event parameters\n- Square brackets before and after item-scoped event parameters\n\nAdditionally, make sure you include all of the [required event parameters](/analytics/devguides/collection/ga4/reference/events). If\nyou don't include a required parameter, you will still see the event and\nparameters in Google Analytics, but Analytics will treat the event as a custom\nevent rather than an ecommerce event.\n| **Note:** The order of the parameters does not matter. You can send them in any order.\n\n### Check the event name\n\nWhen setting up ecommerce events, make sure you use the correct recommended\nevent name. For example, use the event name \"add_to_cart\" rather than\n\"add_to_basket\" to ensure that Analytics registers the event as one of the\nrecommended ecommerce events. Additionally, make sure you spell the event names\ncorrectly and don't have any typos.\n\n### Check the transaction ID\n\nIf the same ecommerce event is triggered twice with the same [transaction ID](https://support.google.com/analytics/answer/12313109),\nGoogle Analytics will only collect the first event and ignore the second event,\neven if you changed some of the values in the new event.\n\nIf you don't see an ecommerce event while testing, try changing the transaction\nID or removing the transaction ID during testing so you see each version of the\nevent.\n\nTroubleshoot duplicate ecommerce events\n---------------------------------------\n\nThe following describes a possible reason why you see duplicate ecommerce events\nin Analytics.\n\n### Use one tag on every page\n\nMake sure you add the Google tag snippet to every page of your website.\nAdditionally, make sure you use the Google tag (gtag.js) or Google Tag Manager,\nbut not both. Using both options will double count certain events and have other\nunintended consequences."]]