Unable to retrieve responsiveSearchAdDescriptions data properly

54 views
Skip to first unread message

はるちゃん

unread,
May 23, 2023, 6:08:54 AM5/23/23
to Google Ads Scripts Forum
Hello, support forum members.
I want to use Google Ads Script to get data about responsive ads.

I have written the following code using the following link
https://blog.ja.dev/entry/blog/2023/02/15/how-to-create-responsive-search-ads-report

However, the data displayed as log is empty.
Have the specifications for these functions changed?
Anyone know how to fix it or reference URL?

function main() {
const spreadsheet = SpreadsheetApp.openByUrl(sheetUrl);
const targetSheet = spreadsheet.getSheetByName("シート1");
const report = AdWordsApp.report(
'SELECT ResponsiveSearchAdDescriptions, ResponsiveSearchAdHeadlines ' +
'FROM AD_PERFORMANCE_REPORT ' +
'WHERE AdType = RESPONSIVE_SEARCH_AD '
);
// reportの中身を確認
Logger.log("report: ", report);
const rows = report.rows();
Logger.log("rows: ", rows);
const descriptionData = [];
const headlineData = [];
// rowsの中身を確認
Logger.log("rows: ", rows);
while (rows.hasNext()) {
const row = rows.next();
Logger.log("row: ", row);
Logger.log("ResponsiveSearchAdDescriptions: ", row['ResponsiveSearchAdDescriptions']);

// 2023/5/23 16:35:25 ResponsiveSearchAdHeadlines::::
const descriptions = JSON.parse(row['ResponsiveSearchAdDescriptions']);
if (descriptions.length === 0) {
Logger.log("ResponsiveSearchAdDescriptions is empty");
} else {
descriptions.forEach(function(v){
Logger.log("v: ", v);
const assetId = v.assetId || "";
const assetText = v.assetText || "";
Logger.log("assetId: ", assetId);
Logger.log("assetText: ", assetText);
targetSheet.appendRow(['description', assetId, assetText]);
});
}

const headlines = JSON.parse(row['ResponsiveSearchAdHeadlines']);
if (headlines.length === 0) {
Logger.log("ResponsiveSearchAdHeadlines is empty");
}
headlines.forEach(function(v){
Logger.log("v: ", v);
const assetId = v.assetId || "";
const assetText = v.assetText || "";
Logger.log("assetId: ", assetId);
Logger.log("assetText: ", assetText);
targetSheet.appendRow(['headline', assetId, assetText]);
}
);
}
} Log:::
2023/5/23 17:00:04 report:
2023/5/23 17:00:04 rows:
2023/5/23 17:00:04 rows:
2023/5/23 17:00:06 row:

Google Ads Scripts Forum

unread,
Jun 27, 2023, 5:10:58 AM6/27/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/pHQwohpDWoA) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Jun 27, 2023, 5:17:50 AM6/27/23
to adwords...@googlegroups.com

Hi,

 

Thank you for reaching out to the Google Ads Scripts Team. Please excuse us for only getting back now as your message failed to be routed to our support queue.

 

Would you be so kind as to provide the following information so we're able to further investigate your concern?:

 

You may send these privately via the Reply to author option. Note that you may need to join the Google Group for you to use this option. If this option is not available on your end still, you may send it through our email (googleadsscr...@google.com) instead.

 

This message is in relation to case "ref:_00D1U1174p._5004Q2mXuYY:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages