Create a Responsive Display Ad

Responsive display ad is the recommended ad type for Smart Display campaigns. To create a responsive display ad, you need to create a new ResponsiveDisplayAdInfo object and set it to an AdGroupAd object.

ResponsiveDisplayAdInfo allows you to reuse assets previously created in your account to set many of its fields, such as

  • marketing_images
  • square_marketing_images
  • headlines
  • long_headline
  • descriptions
  • youtube_videos

Refer to ResponsiveDisplayAdInfo for specs on images and texts that can be used to create an asset for each field. For more details on assets, see the Assets developer guide.

Code example

Creating the responsive display ad

The following snippet creates a responsive display ad, along with instantiating an image asset, and assigning the ad to a new ad group ad.


private static function createResponsiveDisplayAd(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $adGroupResourceName,
    ?int $marketingImageAssetId,
    ?int $squareMarketingImageAssetId
) {
    // Creates a new image asset for marketing image and square marketing image if there are no
    // assets' IDs specified.
    $marketingImageAssetResourceName = $marketingImageAssetId
        ? ResourceNames::forAsset($customerId, $marketingImageAssetId)
        : self::createImageAsset(
            'Marketing Image'
    $squareMarketingImageAssetResourceName = $squareMarketingImageAssetId
        ? ResourceNames::forAsset($customerId, $squareMarketingImageAssetId)
        : self::createImageAsset(
            'Square Marketing Image'

    // Creates a responsive display ad info.
    $responsiveDisplayAdInfo = new ResponsiveDisplayAdInfo([
        // Sets some basic required information for the responsive display ad.
        'headlines' => [new AdTextAsset(['text' => 'Travel'])],
        'long_headline' => new AdTextAsset(['text' => 'Travel the World']),
        'descriptions' => [new AdTextAsset(['text' => 'Take to the air!'])],
        'business_name' => 'Google',
        // Sets the marketing image and square marketing image to the previously created
        // image assets.
        'marketing_images' => [
            new AdImageAsset(['asset' => $marketingImageAssetResourceName])
        'square_marketing_images' => [
            new AdImageAsset(['asset' => $squareMarketingImageAssetResourceName])
        // Optional: Sets call to action text, price prefix and promotion text.
        'call_to_action_text' => 'Shop Now',
        'price_prefix' => 'as low as',
        'promo_text' => 'Free shipping!',

    // Creates an ad group ad with the created responsive display ad info.
    $adGroupAd = new AdGroupAd([
        'ad_group' => $adGroupResourceName,
        'status' => AdGroupAdStatus::PAUSED,
        'ad' => new Ad([
            'final_urls' => [''],
            'responsive_display_ad' => $responsiveDisplayAdInfo

    // Creates an ad group ad operation.
    $adGroupAdOperation = new AdGroupAdOperation();

    // Issues a mutate request to add the ad group ad.
    $adGroupAdServiceClient = $googleAdsClient->getAdGroupAdServiceClient();
    /** @var MutateAdGroupAdsResponse $adGroupAdResponse */
    $adGroupAdResponse = $adGroupAdServiceClient->mutateAdGroupAds(

    // Prints out some information about the newly created ad.
    $adGroupAdResourceName = $adGroupAdResponse->getResults()[0]->getResourceName();
    printf("Added ad group ad named '%s'.%s", $adGroupAdResourceName, PHP_EOL);

Creating the ad image asset

Here is the function that creates the image asset:


private static function createImageAsset(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    string $imageUrl,
    string $imageName
) {
    // Creates a media file.
    $asset = new Asset([
        'name' => $imageName,
        'type' => AssetType::IMAGE,
        'image_asset' => new ImageAsset(['data' => file_get_contents($imageUrl)])

    // Creates an asset operation.
    $assetOperation = new AssetOperation();

    // Issues a mutate request to add the asset.
    $assetServiceClient = $googleAdsClient->getAssetServiceClient();
    $response = $assetServiceClient->mutateAssets($customerId, [$assetOperation]);

    // Prints out information about the newly added asset.
    $assetResourceName = $response->getResults()[0]->getResourceName();
        "A new image asset has been added with resource name: '%s'.%s",

    return $assetResourceName;