บริการผู้ดูแลระบบ Analytics
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บริการผู้ดูแลระบบ Analytics ช่วยให้คุณใช้ Google Analytics Admin API v1
ใน Apps Script ได้ Admin API ของ Google Analytics ช่วยให้เข้าถึงแบบเป็นโปรแกรม
ไปยังข้อมูลการกำหนดค่าของ Google Analytics 4 (GA4) และใช้ได้กับพร็อพเพอร์ตี้ GA4 เท่านั้น
ข้อมูลอ้างอิง
ดูข้อมูลโดยละเอียดเกี่ยวกับบริการนี้ได้ที่ Google Analytics Admin API v1
เช่นเดียวกับบริการขั้นสูงทั้งหมดใน Apps Script บริการ AnalyticsAdmin จะใช้วัตถุ เมธอด และพารามิเตอร์เดียวกันกับ API สาธารณะ
ดูข้อมูลเพิ่มเติมได้ที่วิธีกำหนดลายเซ็นของเมธอด
หากต้องการรายงานปัญหาและค้นหาการสนับสนุนอื่นๆ โปรดดูหน้าการสนับสนุน Google Analytics Admin API v1
โค้ดตัวอย่าง
เรียกใช้รายงาน
ตัวอย่างจะแสดงรายการบัญชี Google Analytics ทั้งหมดที่ผู้ใช้เข้าถึงได้โดยการเรียกใช้เมธอด accounts.list()
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThe Analytics Admin service in Apps Script enables programmatic access to Google Analytics 4 (GA4) configuration data using the Google Analytics Admin API v1.\u003c/p\u003e\n"],["\u003cp\u003eIt is an advanced service that requires enabling before use and is exclusively compatible with GA4 properties.\u003c/p\u003e\n"],["\u003cp\u003eThis service mirrors the objects, methods, and parameters of the public API, providing consistent functionality.\u003c/p\u003e\n"],["\u003cp\u003eSupport and issue reporting can be found on the Google Analytics Admin API v1 support page.\u003c/p\u003e\n"],["\u003cp\u003eA provided sample code demonstrates listing all Google Analytics accounts accessible to the current user.\u003c/p\u003e\n"]]],[],null,["# Analytics Admin Service\n\nThe Analytics Admin service allows you to use the [Google Analytics Admin API v1](/analytics/devguides/config/admin/v1)\nin Apps Script. The Google Analytics Admin API allows for programmatic access\nto the Google Analytics 4 (GA4) configuration data and is only compatible with GA4 properties.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the [Google Analytics Admin API v1](/analytics/devguides/config/admin/v1/rest).\n\nLike all advanced services in Apps Script, the AnalyticsAdmin service uses the\nsame objects, methods, and parameters as the public API. For more information,\nsee [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[Google Analytics Admin API v1 support page](/analytics/devguides/config/admin/v1/help).\n\nSample code\n-----------\n\n### Run a report\n\nThe sample lists all the Google Analytics accounts available to a user by calling\nthe [accounts.list()](/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/list)\nmethod. \nadvanced/analyticsAdmin.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/analyticsAdmin.gs) \n\n```javascript\n/**\n * Logs the Google Analytics accounts accessible by the current user.\n */\nfunction listAccounts() {\n try {\n accounts = AnalyticsAdmin.Accounts.list();\n if (!accounts.items || !accounts.items.length) {\n console.log('No accounts found.');\n return;\n }\n\n for (let i = 0; i \u003c accounts.items.length; i++) {\n const account = accounts.items[i];\n console.log('Account: name \"%s\", displayName \"%s\".', account.name, account.displayName);\n }\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```"]]