Skip to content

Instantly share code, notes, and snippets.

@chkk525
Created February 18, 2023 12:55
Show Gist options
  • Save chkk525/c41e933d0b4c55275b5c6f73dc575141 to your computer and use it in GitHub Desktop.
Save chkk525/c41e933d0b4c55275b5c6f73dc575141 to your computer and use it in GitHub Desktop.
Responsive search Adsのheadlineとdescriptionのtextとasset idを取得するAdwords Script
function main() {
const sheetUrl = "SHEET_URL";
const spreadsheet = SpreadsheetApp.openByUrl(sheetUrl);
const targetSheet = spreadsheet.getSheetByName("RSA");
const report = AdWordsApp.report(
'SELECT ResponsiveSearchAdDescriptions, ResponsiveSearchAdHeadlines ' +
'FROM AD_PERFORMANCE_REPORT ' +
'WHERE AdType = RESPONSIVE_SEARCH_AD ' +
'DURING LAST_7_DAYS'
);
const rows = report.rows();
const descriptionData = [];
const headlineData = [];
while (rows.hasNext()) {
const row = rows.next();
const descriptions = JSON.parse(row['ResponsiveSearchAdDescriptions']);
descriptions.forEach(function(v){
targetSheet.appendRow(['description', v['assetId'], v['assetText']])
})
const headlines = JSON.parse(row['ResponsiveSearchAdHeadlines']);
headlines.forEach(function(v){
targetSheet.appendRow(['headline', v['assetId'], v['assetText']])
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment