ディスプレイ&ビデオ 360 API と構造化データファイルに関するご意見やフィードバックをお寄せいただくには、
Google 広告および測定のコミュニティ サーバーの公式ディスプレイ&ビデオ 360 API と構造化データファイル Discord チャンネルにご参加ください。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
動画クリエイティブを作成する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
動画クリエイティブを作成する方法は次のとおりです。
Java
// Provide the parent advertiser ID to create the creative under.
long advertiserId = advertiser-id;
// Provide the display name of the creative.
String displayName = display-name;
// Provide the media ID of the uploaded video file.
long videoMediaId = video-media-id;
// Provide the URL of the page that the creative redirects to and the name
// of the click tag used in the exit event.
String exitEventUrl = exit-event-url;
String exitEventName = exit-event-name;
// Create a creative object.
Creative creative =
new Creative()
.setDisplayName(displayName)
.setEntityStatus("ENTITY_STATUS_ACTIVE")
.setHostingSource("HOSTING_SOURCE_HOSTED")
.setCreativeType("CREATIVE_TYPE_VIDEO");
// Assign the video asset to a role.
AssetAssociation assetAssociation =
new AssetAssociation()
.setAsset(new Asset().setMediaId(videoMediaId))
.setRole("ASSET_ROLE_MAIN");
// Create and set the list of creative assets.
creative.setAssets(ImmutableList.of(assetAssociation));
// Create an exit event.
ExitEvent exitEvent =
new ExitEvent()
.setName(exitEventName)
.setType("EXIT_EVENT_TYPE_DEFAULT")
.setUrl(exitEventUrl);
// Create and set the list of exit events for the creative.
creative.setExitEvents(ImmutableList.of(exitEvent));
// Configure the create request.
Creatives.Create request = service.advertisers().creatives().create(advertiserId, creative);
// Send the request.
Creative response = request.execute();
// Display ID of the new creative.
System.out.printf("Creative was created with ID %s.", response.getCreativeId());
Python
# Provide the parent advertiser ID to create the creative under.
advertiser_id = advertiser-id
# Provide the display name of the creative.
display_name = display-name
# Provide the media ID of the uploaded video file.
video_media_id = video-media-id
# Provide the URL of the page that the creative redirects to and the name of the
# click tag used in the exit event.
exit_event_url = exit-event-url
exit_event_name = exit-event-name
# Build the creative object.
creative_obj = {
"displayName": display_name,
"entityStatus": "ENTITY_STATUS_ACTIVE",
"hostingSource": "HOSTING_SOURCE_HOSTED",
"creativeType": "CREATIVE_TYPE_VIDEO",
"assets": [{
"asset": {"mediaId": video_media_id},
"role": "ASSET_ROLE_MAIN",
}],
"exitEvents": [{
"name": exit_event_name,
"type": "EXIT_EVENT_TYPE_DEFAULT",
"url": exit_event_url,
}],
}
# Create the creative.
creative_response = (
service.advertisers()
.creatives()
.create(advertiserId=advertiser_id, body=creative_obj)
.execute()
)
# Print the resulting creative ID.
print(f'Creative was created with ID {creative_response["creativeId"]}.')
PHP
// Provide the parent advertiser ID to create the creative under.
$advertiserId = advertiser-id;
// Provide the display name of the creative.
$displayName = display-name;
// Provide the media ID of the uploaded video file.
$videoMediaId = video-media-id;
// Provide the URL of the page that the creative redirects to and the name
// of the click tag used in the exit event.
$exitEventUrl = exit-event-url;
$exitEventName = exit-event-name;
// Create a creative object.
$creative = new Google_Service_DisplayVideo_Creative();
$creative->setDisplayName($displayName);
$creative->setEntityStatus('ENTITY_STATUS_ACTIVE');
$creative->setHostingSource('HOSTING_SOURCE_HOSTED');
$creative->setCreativeType('CREATIVE_TYPE_VIDEO');
// Create an exit event.
$exitEvent = new Google_Service_DisplayVideo_ExitEvent();
$exitEvent->setName($exitEventName);
$exitEvent->setType('EXIT_EVENT_TYPE_DEFAULT');
$exitEvent->setUrl($exitEventUrl);
$creative->setExitEvents(array($exitEvent));
// Assign the video asset to a role.
$assetAssociation = new Google_Service_DisplayVideo_AssetAssociation();
$asset = new Google_Service_DisplayVideo_Asset();
$asset->setMediaId($videoMediaId);
$assetAssociation->setAsset($asset);
$assetAssociation->setRole('ASSET_ROLE_MAIN');
$creative->setAssets(array($assetAssociation));
// Upload and set the asset and create the video creative under the
// given advertiser.
try {
$result = $this->service->advertisers_creatives->create(
$advertiserId,
$creative
);
} catch (\Exception $e) {
$this->renderError($e);
return;
}
// Display ID of the new creative.
printf('<p>Creative was created with ID %s.</p>', $result['creativeId']);
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2026-05-13 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2026-05-13 UTC。"],[],[]]