アナリティクス管理サービス
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
アナリティクス管理サービスを使用すると、Apps Script で Google Analytics Admin API v1 を使用できます。Google アナリティクス Admin API を使用すると、Google アナリティクス 4(GA4)の設定データにプログラムでアクセスできます。この API は GA4 プロパティとのみ互換性があります。
リファレンス
このサービスの詳細については、Google Analytics Admin API v1 をご覧ください。
Apps Script のすべての高度なサービスと同様に、AnalyticsAdmin サービスでは、公開 API と同じオブジェクト、メソッド、パラメータを使用します。詳細については、メソッド シグネチャの決定方法をご覧ください。
問題を報告したり、その他のサポートを利用したりするには、Google Analytics Admin API v1 のサポートページをご覧ください。
サンプルコード
レポートを実行する
このサンプルでは、accounts.list() メソッドを呼び出して、ユーザーが利用できるすべての Google アナリティクス アカウントを一覧表示します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 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```"]]