Created
February 18, 2023 12:55
-
-
Save chkk525/c41e933d0b4c55275b5c6f73dc575141 to your computer and use it in GitHub Desktop.
Responsive search Adsのheadlineとdescriptionのtextとasset idを取得するAdwords Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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