애널리틱스 관리 서비스는 Apps Script에서 Google 애널리틱스 Admin API v1을 사용할 수 있도록 지원합니다. Google 애널리틱스 Admin API를 사용하면 Google 애널리틱스 4 (GA4) 구성 데이터에 프로그래매틱 방식으로 액세스할 수 있으며 GA4 속성하고만 호환됩니다.
/** * Logs the Google Analytics accounts accessible by the current user. */functionlistAccounts(){try{accounts=AnalyticsAdmin.Accounts.list();if(!accounts.items||!accounts.items.length){console.log('No accounts found.');return;}for(leti=0;i < accounts.items.length;i++){constaccount=accounts.items[i];console.log('Account: name "%s", displayName "%s".',account.name,account.displayName);}}catch(e){// TODO (Developer) - Handle exceptionconsole.log('Failed with error: %s',e.error);}}
[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```"]]