James here, a member of the Google Ads Scripts Team. Thank you for reaching out to us.
To create a script that allows you to track the data/metrics at ad group level and export it in a spreadsheet, you need to implement
Ads script reporting along with
GAQL that utilizes the
ad_group report type. Since you’re also looking to export it to a spreadsheet, you may also follow
this guide for sample implementation. Moreover, you may also use our
query builder to in order to construct your query.
Regards,