Aquí tienes la segunda forma que indico en el vídeo.
Script para descargar los términos de búsqueda de Performance Max de toda la cuenta:
function main() {
let ss = SpreadsheetApp.openByUrl('IntroduceAquíLaUrlDeTuHojaDeGoogleSheets'); // enter sheet url between the quotes
let query = AdsApp.report(
`
SELECT
customer_search_term_insight.category_label,
metrics.clicks,
metrics.impressions,
metrics.ctr,
metrics.conversions,
metrics.conversions_value,
metrics.search_volume
FROM customer_search_term_insight
WHERE
segments.date DURING LAST_30_DAYS
ORDER BY
metrics.clicks DESC
`
);
query.exportToSheet(ss.getSheetByName('IntroduceAquíElNombreDeLaPestañaDeGoogleSheets'));
}
Script para descargar los términos de búsqueda de una campaña concreta de máximo rendimiento:
function main() {
let ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1r0Egq8tMo3hywscS5pDEjYEiUy6tSozRawiD1AiFk8A/edit#gid=0'); // enter sheet url between the quotes
let query = AdsApp.report(
`
SELECT
campaign_search_term_insight.category_label,
metrics.clicks,
metrics.impressions,
metrics.conversions,
metrics.conversions_value
FROM campaign_search_term_insight
WHERE
segments.date DURING LAST_30_DAYS
AND campaign_search_term_insight.campaign_id = '20393069406'
ORDER BY metrics.conversions
`
);
query.exportToSheet(ss.getSheetByName('Hoja 1'));
}