แบบเป็นโปรแกรมภายใน Google Apps Script โดยใช้บริการผู้ดูแลระบบ Analytics
บริการผู้ดูแลระบบ Analytics ช่วยให้คุณใช้ Google Analytics Admin API v1 ใน Google Apps Script ได้ Admin API ของ Google Analytics ให้สิทธิ์เข้าถึงข้อมูลการกำหนดค่าของ 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);}}