ครีเอทีฟโฆษณาที่แสดงโดยโฆษณา Demand Gen จะสร้างขึ้นในแหล่งข้อมูล AdGroupAd ของตัวเอง ซึ่งต่างจากครีเอทีฟโฆษณาที่แสดงโดยรายการโฆษณาประเภทอื่นๆ ชิ้นงานรูปภาพและวิดีโอที่กําหนดให้กับโฆษณาเพื่อสร้างครีเอทีฟโฆษณาเหล่านี้ จะแสดงใน API ของ Display & Video 360 โดยทรัพยากร AdAsset
ก่อนสร้างทรัพยากร AdGroupAd ให้สร้างทรัพยากร AdAsset ที่เกี่ยวข้องซึ่งโฆษณาจะใช้หากยังไม่มี หากสร้างไว้ก่อนหน้านี้โดยใช้ UI หรือ API คุณจะเรียกข้อมูลชิ้นงานที่มีอยู่ได้โดยใช้บริการ advertisers.adAssets get
และเมธอด list
ระบบจะสร้างแหล่งข้อมูลรูปภาพและวิดีโอ AdAsset โดยใช้วิธีการต่างๆ ดังนี้
- ต้องอัปโหลดชิ้นงานรูปภาพไปยัง Display & Video 360 โดยใช้วิธี
advertisers.adAssets.upload - ต้องเชื่อมโยงชิ้นงานวิดีโอโดยใช้รหัสวิดีโอ YouTube และสร้างโดยใช้วิธี
advertisers.adAssets.create
ระบบจะใช้ adAssetId ของทรัพยากร AdAsset เพื่อเชื่อมโยงชิ้นงานกับโฆษณา Demand Gen
อัปโหลดชิ้นงานรูปภาพ
อัปโหลดไฟล์รูปภาพเพื่อสร้างAD_ASSET_TYPE_IMAGEชิ้นงานที่ใช้เป็น
แบนเนอร์ที่แสดงร่วม โลโก้ และรูปภาพทางการตลาดได้
วิธีอัปโหลดชิ้นงานรูปภาพเพื่อสร้างทรัพยากร AdAsset
มีดังนี้
Python
# Import the object used as the media body for the upload request. from apiclient.http import MediaFileUpload # Provide the parent advertiser ID to upload the media file under. advertiser_id = advertiser-id # Provide the filename and local path to the media file. asset_filename = asset-filename asset_path = asset-path # Create the request body. body = {"filename": asset_filename, "adAssetType": "AD_ASSET_TYPE_IMAGE"} # Create the upload object and use a default MIME type if not identified. media = MediaFileUpload(asset_path) if not media.mimetype(): media = MediaFileUpload(asset_path, "application/octet-stream") # Upload the asset. upload_response = ( service.advertisers() .adAssets() .upload(advertiserId=advertiser_id, body=body, media_body=media) .execute() ) # Display the new ad asset. print(f"Ad asset {upload_response['adAsset']['name']} was created.")
สร้างชิ้นงาน YouTube
ระบุรหัสวิดีโอ YouTube เพื่อสร้างAD_ASSET_TYPE_YOUTUBE_VIDEOชิ้นงานที่
ใช้ในโฆษณาวิดีโอ Demand Gen ได้
วิธีสร้างชิ้นงานวิดีโอ YouTube เพื่อสร้างแหล่งข้อมูล AdAsset มีดังนี้
Python
# Provide the ID of the parent advertiser. advertiser_id = advertiser-id # Provide the ID of the parent insertion order. youtube_video_id = youtube-video-id # Create a line item object with example values. ad_asset_create_body = { "adAsset": { "adAssetType": "AD_ASSET_TYPE_YOUTUBE_VIDEO", "youtubeVideoAsset": {"youtubeVideoId": youtube_video_id}, } } # Build and execute request. response = ( service.advertisers() .adAssets() .create(advertiserId=advertiser_id, body=ad_asset_create_body) .execute() ) # Display the new ad asset. print(f"Ad asset {response['name']} was created.")