The Analytics service allows you to use the Google Analytics Management API and Reporting APIs in Apps Script. These APIs gives Analytics users the ability to get information about the structure of their account and run reports on how it is performing.
Reference
For detailed information on this service, see the reference documentation for the various Google Analytics APIs:
- Core Reporting API
- Management API
- Metadata API
- Multi-Channel Funnels Reporting API
- Real Time Reporting API
Like all advanced services in Apps Script, the Analytics service uses the same objects, methods, and parameters as the public API. For more information, see How method signatures are determined.
To report issues and find other support, see the corresponding support pages:
- Core Reporting API support
- Management API support
- Metadata API support
- Multi-Channel Funnels Reporting API support
- Real Time Reporting API support
Sample code
The sample code below version 3 of the Management API.
List account structure
The sample lists all of the Google Analytics accounts, web properties, and profiles that the current user can access.
Run a report
The sample runs a report to retrieve the top 25 keywords and traffic sources and stores the results in a new spreadsheet.