Analytics Admin Service Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Analytics Admin service in Apps Script allows programmatic access to Google Analytics 4 configuration data via the Google Analytics Admin API v1.
This is an advanced service that requires enablement before use and is only compatible with GA4 properties.
The service uses the same objects, methods, and parameters as the public Google Analytics Admin API v1.
Sample code demonstrates how to list Google Analytics accounts accessible by a user using the
accounts.list()method.
The Analytics Admin service allows you to use theGoogle Analytics Admin API v1in Apps Script. The Google Analytics Admin API allows for programmatic accessto the Google Analytics 4 (GA4) configuration data and is only compatible with GA4 properties.
Note: This is an advanced service that must beenabled before use.Reference
For detailed information on this service, see theGoogle Analytics Admin API v1.
Like all advanced services in Apps Script, the AnalyticsAdmin service uses thesame objects, methods, and parameters as the public API. For more information,seeHow method signatures are determined.
To report issues and find other support, see theGoogle Analytics Admin API v1 support page.
Sample code
Run a report
The sample lists all the Google Analytics accounts available to a user by callingtheaccounts.list()method.
/** * 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);}}
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.