[null,null,["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eGoogle Ads scripts facilitate the creation, retrieval, and reporting of various ad types, including expanded text ads, via dedicated methods and builders.\u003c/p\u003e\n"],["\u003cp\u003eAd inspection involves using \u003ccode\u003easType()\u003c/code\u003e to access type-specific fields like descriptions, ensuring proper type verification with \u003ccode\u003eisType()\u003c/code\u003e to prevent errors.\u003c/p\u003e\n"],["\u003cp\u003eReporting on ads, including type-specific fields and performance metrics, can be achieved by querying the \u003ccode\u003ead_group_ad\u003c/code\u003e view with relevant conditions and utilizing the reporting features in scripts.\u003c/p\u003e\n"],["\u003cp\u003eResponsive display ads now support multiple assets, but legacy ads have limited features; both types remain operational, but API interactions differ.\u003c/p\u003e\n"]]],[],null,["# Ad Types\n\nGoogle Ads supports a variety of ad types, such as text, image, and mobile ads.\nThis guide covers how to create, retrieve, and report on ads using Google Ads\nscripts. For an overview of all ad types supported by Google Ads, see the\n[API guide](/google-ads/api/docs/ads/ad-types).\n| **Note:** Responsive display ads have gained support for multiple text, image, and video assets in the same ad. Legacy responsive display ads do not support these new features. Both new and legacy ads will continue to serve as usual, but the API for retrieving and manipulating responsive display ads has changed. Please see [Handling Legacy Responsive Display Ads](/google-ads/scripts/docs/features/responsive-display-ads).\n\nCreation\n--------\n\nScripts can create ads using the\n[`newAd()`](/google-ads/scripts/docs/reference/adsapp/adsapp_adgroup#newAd)\nmethod on\n[`AdGroup`](/google-ads/scripts/docs/reference/adsapp/adsapp_adgroup)\ninstances. This returns an\n[`AdBuilderSpace`](/google-ads/scripts/docs/reference/adsapp/adsapp_adbuilderspace)\nthat creates [builders](/google-ads/scripts/docs/concepts/builders) for\nsupported ad types.\n\nThe following snippet demonstrates how to create an expanded text ad: \n\n let adOperation = adGroup.newAd().expandedTextAdBuilder()\n .withHeadlinePart1(\"First headline part\")\n .withHeadlinePart2(\"Second headline part\")\n .withDescription(\"Ad description\")\n .withFinalUrl(\"http://www.example.com\")\n .withPath1(\"path1\") // optional\n .withPath2(\"path2\") // optional\n .build();\n\nInspection\n----------\n\nSome information associated with all ad types is immediately available from an\n[`Ad`](/google-ads/scripts/docs/reference/adsapp/adsapp_ad), such as an\nad's ID and approval status. Additionally, any ad can be paused, enabled, or\nremoved.\n\nTo access fields specific to an ad's type, such as an expanded text ad's\ndescription, use the\n[`asType()`](/google-ads/scripts/docs/reference/adsapp/adsapp_ad#asType)\nmethod to create an\n[`AdViewSpace`](/google-ads/scripts/docs/reference/adsapp/adsapp_adviewspace).\nThis provides access to an extended version of the\n[`Ad`](/google-ads/scripts/docs/reference/adsapp/adsapp_ad) that exposes\ntype-specific methods.\n\nThe following snippet gets the description of every expanded text ad: \n\n const iterator = AdsApp.ads().withCondition(\"Type = EXPANDED_TEXT_AD\").get();\n while (iterator.hasNext()) {\n let ad = iterator.next();\n let expandedTextAd = ad.asType().expandedTextAd();\n let description = expandedTextAd.getDescription();\n }\n\nNotice that the condition `Type = EXPANDED_TEXT_AD` ensures every ad from the\niterator is an expanded text ad. Attempting to view an ad with an incorrect\ntype will result in an error that stops your script's execution, so it's\nimportant to view type-specific fields only when an ad's type is known.\n\nThe following snippet shows how to determine if an ad is of the correct type\nusing the\n[`Ad.isType()`](/google-ads/scripts/docs/reference/adsapp/adsapp_ad#isType)\nmethod: \n\n if (ad.isType().expandedTextAd()) {\n let expandedTextAd = ad.asType().expandedTextAd();\n let headlinePart1 = expandedTextAd.getHeadlinePart1();\n let headlinePart2 = expandedTextAd.getHeadlinePart2();\n }\n\n\u003cbr /\u003e\n\nReporting\n---------\n\nThe [`ad_group_ad` view](/google-ads/api/fields/latest/ad_group_ad) can also be\nused to query type-specific ad fields in addition to regular stats, such as\n[`ad_group_ad.expanded_text_ad.headline_part1`](/google-ads/api/fields/latest/ad_group_ad#ad_group_ad.ad.expanded_text_ad.headline_part1).\nThe following snippet shows how to retrieve the stats for all expanded text ads\nthat contain \"Discount Sales\" in headline 1: \n\n const results = AdsApp.search(\n \"SELECT ad_group_ad.ad_group.id, \" +\n \"ad_group_ad.id, \" +\n \"ad_group_ad.expanded_text_ad.headline_part1, \" +\n \"ad_group_ad.expanded_text_ad.headline_part2, \" +\n \"metrics.clicks, \" +\n \"metrics.impressions, \" +\n \"metrics.cost\" +\n \"FROM ad_group_ad \" +\n \"WHERE ad_group_ad.expanded_text_ad.headline_part1 = 'Discount Sales' \" +\n \"AND segments.date DURING LAST_7_DAYS\");\n\n while (results.hasNext()) {\n let row = results.next();\n let headlinePart1 = row.adGroupAd.expandedTextAd.headlinePart1;\n let headlinePart2 = row.adGroupAd.expandedTextAd.headlinePart2;\n ...\n }\n\nSee the [reports guide](/google-ads/scripts/docs/features/reports) for\nmore information on reporting in scripts."]]