Google Analytics(分析)管理服务
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 Analytics Admin 服务以编程方式在 Google Apps 脚本中完成。
通过 Analytics Admin 服务,您可以在 Google Apps 脚本中使用 Google Analytics Admin API v1。Google Analytics Admin API 支持以编程方式访问 Google Analytics 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);}}