Handling Responsive Display Ads
Stay organized with collections
Save and categorize content based on your preferences.
Creating an ad iterator with condition Type = RESPONSIVE_DISPLAY_AD
will
currently iterate over legacy ads only. This condition is deprecated; please
update existing code to explicitly use Type = LEGACY_RESPONSIVE_DISPLAY_AD
. To
create an ad iterator over ads that support multiple text, image, and video
assets, use the condition Type = MULTI_ASSET_RESPONSIVE_DISPLAY_AD
.
The following snippet illustrates some of the API differences and similarities
between the two types of responsive display ads. Please read the
Responsive Display Ad reference
for more details.
// let legacyRdaIterator = AdsApp.ads().withCondition("Type = RESPONSIVE_DISPLAY_AD").get();
let legacyRdaIterator = AdsApp.ads().withCondition("Type = LEGACY_RESPONSIVE_DISPLAY_AD").get();
while (legacyRdaIterator.hasNext()) {
let responsiveDisplayAd = legacyRdaIterator.next().asType().responsiveDisplayAd();
// Legacy responsive display ads have just one long headline.
let longHeadline = responsiveDisplayAd.getLongHeadline();
// And they have one short headline, too.
let shortHeadline = responsiveDisplayAd.getShortHeadline();
// This call to .getHeadlines() returns null, because the method is not
// meaningful when called on a legacy responsive display ad.
assert(responsiveDisplayAd.getHeadlines() === null);
// ... etc. ...
}
let rdaIterator = AdsApp.ads().withCondition("Type = MULTI_ASSET_RESPONSIVE_DISPLAY_AD").get();
while (rdaIterator.hasNext()) {
let responsiveDisplayAd = rdaIterator.next().asType().responsiveDisplayAd();
// Responsive display ads have just one long headline.
let longHeadline = responsiveDisplayAd.getLongHeadline();
// But they can have multiple short headline text assets.
let shortHeadlineAssets = responsiveDisplayAd.getHeadlines();
// This call to .getShortHeadline() returns null, because the method is only
// meaningful when called on a legacy responsive display ad.
assert(responsiveDisplayAd.getShortHeadline() === null);
// ... etc. ...
}
let rdaAndLegacyIterator = AdsApp.ads().withCondition("Type IN [LEGACY_RESPONSIVE_DISPLAY_AD, MULTI_ASSET_RESPONSIVE_DISPLAY_AD]").get();
while (rdaAndLegacyIterator.hasNext()) {
let responsiveDisplayAd = legacyRdaIterator.next().asType().responsiveDisplayAd();
let longHeadline = responsiveDisplayAd.getLongHeadline();
// The .isLegacy() method can be used to differentiate between responsive
// display ad types within an iterator over both.
if (responsiveDisplayAd.isLegacy()) {
let shortHeadline = responsiveDisplayAd.getShortHeadline();
// ... etc. ...
} else {
let shortHeadlineAssets = responsiveDisplayAd.getHeadlines();
// ... etc. ...
}
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-25 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThe condition \u003ccode\u003eType = RESPONSIVE_DISPLAY_AD\u003c/code\u003e is deprecated and now refers to \u003ccode\u003eLEGACY_RESPONSIVE_DISPLAY_AD\u003c/code\u003e only; use \u003ccode\u003eType = MULTI_ASSET_RESPONSIVE_DISPLAY_AD\u003c/code\u003e for ads with multiple assets.\u003c/p\u003e\n"],["\u003cp\u003eLegacy responsive display ads have a single long and short headline accessible via \u003ccode\u003egetLongHeadline()\u003c/code\u003e and \u003ccode\u003egetShortHeadline()\u003c/code\u003e, while \u003ccode\u003egetHeadlines()\u003c/code\u003e returns null.\u003c/p\u003e\n"],["\u003cp\u003eMulti-asset responsive display ads have one long headline (\u003ccode\u003egetLongHeadline()\u003c/code\u003e) and multiple short headlines (\u003ccode\u003egetHeadlines()\u003c/code\u003e), while \u003ccode\u003egetShortHeadline()\u003c/code\u003e returns null for them.\u003c/p\u003e\n"],["\u003cp\u003eTo iterate over both ad types, use \u003ccode\u003eType IN [LEGACY_RESPONSIVE_DISPLAY_AD, MULTI_ASSET_RESPONSIVE_DISPLAY_AD]\u003c/code\u003e and differentiate with \u003ccode\u003eisLegacy()\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Handling Responsive Display Ads\n\nCreating an ad iterator with condition `Type = RESPONSIVE_DISPLAY_AD` will\ncurrently iterate over legacy ads only. This condition is deprecated; please\nupdate existing code to explicitly use `Type = LEGACY_RESPONSIVE_DISPLAY_AD`. To\ncreate an ad iterator over ads that support multiple text, image, and video\nassets, use the condition `Type = MULTI_ASSET_RESPONSIVE_DISPLAY_AD`.\n\nThe following snippet illustrates some of the API differences and similarities\nbetween the two types of responsive display ads. Please read the\n[Responsive Display Ad reference](/google-ads/scripts/docs/reference/adsapp/adsapp_responsivedisplayad)\nfor more details. \n\n // let legacyRdaIterator = AdsApp.ads().withCondition(\"Type = RESPONSIVE_DISPLAY_AD\").get();\n let legacyRdaIterator = AdsApp.ads().withCondition(\"Type = LEGACY_RESPONSIVE_DISPLAY_AD\").get();\n while (legacyRdaIterator.hasNext()) {\n let responsiveDisplayAd = legacyRdaIterator.next().asType().responsiveDisplayAd();\n\n // Legacy responsive display ads have just one long headline.\n let longHeadline = responsiveDisplayAd.getLongHeadline();\n\n // And they have one short headline, too.\n let shortHeadline = responsiveDisplayAd.getShortHeadline();\n\n // This call to .getHeadlines() returns null, because the method is not\n // meaningful when called on a legacy responsive display ad.\n assert(responsiveDisplayAd.getHeadlines() === null);\n\n // ... etc. ...\n }\n\n let rdaIterator = AdsApp.ads().withCondition(\"Type = MULTI_ASSET_RESPONSIVE_DISPLAY_AD\").get();\n while (rdaIterator.hasNext()) {\n let responsiveDisplayAd = rdaIterator.next().asType().responsiveDisplayAd();\n\n // Responsive display ads have just one long headline.\n let longHeadline = responsiveDisplayAd.getLongHeadline();\n\n // But they can have multiple short headline text assets.\n let shortHeadlineAssets = responsiveDisplayAd.getHeadlines();\n\n // This call to .getShortHeadline() returns null, because the method is only\n // meaningful when called on a legacy responsive display ad.\n assert(responsiveDisplayAd.getShortHeadline() === null);\n\n // ... etc. ...\n }\n\n let rdaAndLegacyIterator = AdsApp.ads().withCondition(\"Type IN [LEGACY_RESPONSIVE_DISPLAY_AD, MULTI_ASSET_RESPONSIVE_DISPLAY_AD]\").get();\n while (rdaAndLegacyIterator.hasNext()) {\n let responsiveDisplayAd = legacyRdaIterator.next().asType().responsiveDisplayAd();\n let longHeadline = responsiveDisplayAd.getLongHeadline();\n\n // The .isLegacy() method can be used to differentiate between responsive\n // display ad types within an iterator over both.\n if (responsiveDisplayAd.isLegacy()) {\n let shortHeadline = responsiveDisplayAd.getShortHeadline();\n // ... etc. ...\n } else {\n let shortHeadlineAssets = responsiveDisplayAd.getHeadlines();\n // ... etc. ...\n }\n }"]]