As with each sunset, we have the following resources available for you:
AdWords API v201402 Sunset – 2 weeks remaining
As with each sunset, we have the following resources available for you:
Your DFP network is already serving thousands of image, text, and custom ads. But now you want to start monetizing your video content. This two-part blog post will get you started with video ads. We'll start with creating and trafficking your ad using the DFP API, and then show you how to display it using the IMA SDK.
If you're new to video ads, check out this help center article for a little more background. This post shows how to use a VAST redirect creative, so you'll need to host a VAST tag and your video ad before making the creative in DFP. If you just want an example VAST tag to get up and running, you can use the XML here.
Note that this example tag will only return VAST for the first request. Subsequent requests will need to update the correlator timestamp in the URL. The IMA SDK will handle this for you, so there's no problem using this as your example URL.
If your network doesn't have a video ad unit already, you'll need to create one. Set the fields as you would for any other ad unit, but use a size appropriate for video and the VIDEO_PLAYER
environment type.
Size videoSize = new Size();
videoSize.setWidth(640);
videoSize.setHeight(480);
videoSize.setIsAspectRatio(false);
AdUnitSize videoAdUnitSize = new AdUnitSize();
videoAdUnitSize.setSize(videoSize);
videoAdUnitSize.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);
Beginning in v201403, you can create and update VAST redirect creatives with the DFP API. If video features are enabled on your network, creating VAST redirect creatives takes just a few lines of code. Let's start by setting some standard creative fields:
VastRedirectCreative vastRedirectCreative = new VastRedirectCreative();
vastRedirectCreative.setName("My first VAST redirect creative");
vastRedirectCreative.setAdvertiserId(advertiserId);
Now set the size of your video to match your AdUnit:
Size size = new Size();
size.setWidth(640);
size.setHeight(480);
vastRedirectCreative.setSize(size);
Finally, you need to set your VAST XML. For this example, we'll use VAST XML with a linear advertisement. Linear video ads are analogous to television commercials and can play before, after, or in the middle of your content.
vastRedirectCreative.setVastXmlUrl(vastXmlUrl);
vastRedirectCreative.vastRedirectType(VastRedirectType.LINEAR);
Creative[] creatives = creativeService.createCreatives(new Creative[] {
vastRedirectCreative});
Creative masterCreative = creatives[0];
This is your master creative. When working with video, DFP uses CreativeSets which have master and companion creatives. Companion creatives are typically displayed alongside the content video, and tie in with the video ad. The line items you create for video will be associated with a creative set, so you need to create one using your VAST redirect creative as the master. For simplicity, we won't use any companions here.
CreativeSet creativeSet = new CreativeSet();
creativeSet.setName("My VAST Redirect Creative Set");
creativeSet.setMasterCreativeId(masterCreative.getId());
creativeSet.setCompanionCreativeIds(new long[] {});
CreativeSet createdCreativeSet =
creativeSetService.createCreativeSet(creativeSet);
Now we need a line item to serve the video creative set. We'll just highlight the differences for video line items here, so if you aren't familiar with creating line items, check out our complete example on GitHub.
In addition to the usual line item fields, you have the option to set position targeting. Using VideoPositionType.PREROLL will target videos where ads can play before the content starts.
VideoPosition videoPosition = new VideoPosition();
videoPosition.setPositionType(VideoPositionType.PREROLL);
VideoPositionTarget videoPositionTarget = new VideoPositionTarget();
videoPositionTarget.setVideoPosition(videoPosition);
VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
videoPositionTargeting.setTargetedPositions(
new VideoPositionTarget[] {videoPositionTarget});
Video line items can also target content in a variety of ways with ContentTargeting. If your network is connected to a content source you can use your content hierarchies to target a genre, season, or any other hierarchy you configured. If you're unsure of how to get the content metadata hierarchy key IDs, take a look at this example.
// Create content targeting.
ContentMetadataKeyHierarchyTargeting contentMetadataTargeting =
new ContentMetadataKeyHierarchyTargeting();
contentMetadataTargeting.setCustomTargetingValueIds(
new long[] {contentCustomTargetingValueId});
ContentTargeting contentTargeting = new ContentTargeting();
contentTargeting.setTargetedContentMetadata(
new ContentMetadataKeyHierarchyTargeting[] {contentMetadataTargeting});
Now add these to the line item's targeting object. Don't forget to set the environment type to VIDEO_PLAYER
.
Targeting targeting = new Targeting();
targeting.setContentTargeting(contentTargeting);
targeting.setVideoPositionTargeting(videoPositionTargeting);
// Target your video AdUnit
targeting.setInventoryTargeting(inventoryTargeting);
LineItem lineItem = new LineItem();
lineItem.setEnvironmentType(EnvironmentType.VIDEO_PLAYER);
lineItem.setTargeting(targeting);
Make sure to set all the required fields as you would for any other line item, and then create it.
Let’s do a quick recap. We now have an AdUnit for a standard video size, our VastRedirectCreative of a matching size in a CreativeSet, and our video LineItem targeted the AdUnit. If your network has a content source connected, you may have targeted certain content as well.
The last step is to create a LineItemCreativeAssociation to connect the CreativeSet with the LineItem.
LineItemCreativeAssociation lica = new LineItemCreativeAssociation();
lica.setLineItemId(lineItemId);
lica.setCreativeSetId(creativeSetId);
LineItemCreativeAssociation[] licas =
licaService.createLineItemCreativeAssociations(
new LineItemCreativeAssociation[] {lica});
Finally, your video ad is ready to serve. The next question is, how do you actually serve it? Stay tuned for the exciting conclusion: Life of a Video Line Item Part II.
@Override
public VideoProgressUpdate getAdProgress() {
if (currentVideoIsAd() && currentVideo.getDuration() > 0) {
return new VideoProgressUpdate(
video.getCurrentPosition(), video.getDuration())
} else {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
}
@Override
public VideoProgressUpdate getContentProgress() {
if (currentVideoIsContent() && currentVideo.getDuration() > 0) {
return new VideoProgressUpdate(
video.getCurrentPosition(), video.getDuration());
} else {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
}
- (void)adsLoader:(IMAAdsLoader *)loader
adsLoadedWithData:(IMAAdsLoadedData *)adsLoadedData {
self.adsManager = adsLoadedData.adsManager;
// …
self.adsRenderingSettings = [[IMAAdsRenderingSettings alloc] init];
// Show no attribution or countdown timer.
self.adsRenderingSettings.uiElements = @[];
// Or, show only ad attribution.
self.adsRenderingSettings.uiElements = @[kIMAUiElements_AD_ATTRIBUTION];
// Or, show both countdown timer and ad attribution.
self.adsRenderingSettings.uiElements =
@[kIMAUiElements_AD_ATTRIBUTION, kIMAUiElements_COUNTDOWN];
// ...
[self.adsManager initializeWithContentPlayhead:self.contentPlayhead
adsRenderingSettings:self.adsRenderingSettings];
}
This is a friendly reminder that, on February 27, 2015, we will sunset DFP API versions v201311, v201308, and v201306. At that point, requests to these versions will fail. We'll also remove them from our online documentation and the client libraries. If you are currently using one of these versions, this is an excellent time to begin migrating to a supported version. See the release notes for a list of the many new features in our recent API versions.
Going forward, all DFP API versions will follow a consistent deprecation schedule: versions will be supported for one year, deprecated for one quarter, then sunset. This means each of our quarterly API versions will be available for 15 months from the time of release. This deprecation schedule enables us to spend more time improving the latest versions with new features.
Note that v201311 is the last version that supports ClientLogin, which was officially deprecated across all of Google on April 20, 2012. If your application is not yet using OAuth2, you must migrate before Feb 27, 2015.
If this task seems daunting, don't fret, we have you covered. On our Developer page, we have a helpful OAuth2 guide to make sure the transition is as smooth as possible. As an added reason to switch, the DFP API now supports OAuth2 service accounts. You can add service account users directly in the DFP UI. For more information, see here for a guide on how to use a service account user with the DFP API.
If you have any feedback or comments about this deprecation, or the API in general, please feel free to leave them on our forum.
account.name
property will have the company name or, in its absence, the contact name. If you still want to show the account ID, just use the id field.