![]() |
Google Ads Scripts Team |
--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/4389f20b-cb1f-4442-817f-0147deae4cf5n%40googlegroups.com.
Hi,
In order to investigate the issue further,kindly provide us with the below details
Hi,
Hi Yaniv,
As informed earlier, the getHeadline() method is returning a null value because the ad type is text ad. As you are trying to get the headline and description for responsive search ads (RSA), you may use the getHeadlines and getDescriptions methods from the AdsApp.ResponsiveSearchAd.
Additionally, you may use the ad_group_ad_asset_view report to fetch the headline and description. Please check the below query:
SELECT campaign.name, ad_group_ad.ad.id, ad_group_ad.ad.responsive_search_ad.headlines, ad_group_ad.ad.responsive_search_ad.descriptions, metrics.clicks, metrics.impressions, metrics.conversions FROM ad_group_ad_asset_view WHERE metrics.impressions > 0 AND segments.date DURING LAST_30_DAYS
Hope this clarifies! Let us know if you have any further questions.
Hi Yaniv,
Unfortunately, it is not possible in the Google Ads API to pull the performance data except impressions for RSA assets. The “ad_group_ad_asset_view” only exposes metrics.impressions for assets that are part of an ad_group_ad of type RESPONSIVE_SEARCH_AD (RSA). This means that if several metrics are included in the search query, only “metrics.impressions” will be returned for rows that correspond to an RSA. I would recommend that you use the below code to display the headlines data.
while (rows.hasNext()) {
var row = rows.next();
const jsonString = JSON.stringify(row);
const data = JSON.parse(jsonString);
findHeadlinesAndDescriptions(data);
}
}
function findHeadlinesAndDescriptions(obj, context) {
if (typeof obj === 'object') {
for (const key in obj) {
if (Array.isArray(obj[key])) {
for (const item of obj[key]) {
findHeadlinesAndDescriptions(item, key);
}
} else if (typeof obj[key] === 'object') {
findHeadlinesAndDescriptions(obj[key], key);
} else if (key === 'text') {
console.log(`${context === 'headlines' ? 'Headline' : 'Description'}: ${obj[key]}`);
} else if (key === 'assetPerformanceLabel') {
console.log(`Asset Performance Label: ${obj[key]}`);
}
}
}
}
I hope this helps! Kindly get back to us if you still face any issues.