Create a Demand Gen ad

A Demand Gen ad builds the creative served to a user when an ad auction is won. AdGroupAd resources configure the relevant creative options under the union field ad_details.

Configure ad details

There are four types of Demand Gen ads. Each AdGroupAd resource can only be a single type. Each type is configured in individual field under the union field ad_details:

A link to the relevant ad type requirements is available in the description of each field. Only one of these fields can be populated when creating an AdGroupAd resource.

Image dimension and resolution requirements by type

Each ad type requires different sizes of image assets.

The following table lists the image types and relevant file restrictions:

Image type
Companion banner

Maximum file size: 150 KB

Dimensions: 300x60

Landscape image

Maximum file size: 5120 KB

Recommended dimensions: 1200x628, Minimum: 600x314

Logo image

Maximum file size: 5120 KB

Recommended dimensions: 1200x1200, Minimum: 128x128

Portrait image

Maximum file size: 5120 KB

Recommended dimensions: 960x1200, Minimum: 480x600

Square image

Maximum file size: 5120 KB

Recommended dimensions: 1200x1200, Minimum: 300x300

Create an ad

Here's how to create a Demand Gen video ad:

Python

# Provide the ID of the parent advertiser.
advertiser_id = advertiser-id

# Provide the ID of the parent line item.
ad_group_id = ad-group-id

# Provide the display name of the ad.
display_name = display-name

# Provide the information for the ad creative.
final_ad_url = final-ad-url
call_to_action = call-to-action
headline = headline
long_headline = long-headline
description = description
business_name = business-name
youtube_asset_id = youtube-video-asset-id
logo_asset_id = logo-asset-id

# Create an ad object with example values.
ad_obj = {
    "adGroupId": ad_group_id,
    "displayName": display_name,
    "entityStatus": "ENTITY_STATUS_PAUSED",
    "demandGenVideoAd": {
        "finalUrl": final_ad_url,
        "callToAction": call_to_action,
        "headlines": [headline],
        "longHeadlines": [long_headline],
        "descriptions": [description],
        "businessName": business_name,
        "videos": [{"videoAssetId": youtube_asset_id}],
        "logo": {"assetId": logo_asset_id}
    }
}

# Build and execute request.
response = (
    service.advertisers()
    .adGroupAds()
    .create(advertiserId=advertiser_id, body=ad_obj)
    .execute()
)

# Display the new ad.
print(f"Demand Gen ad {response['name']} was created.")