Video Campaigns

AdWords scripts allow you to manage and report on your YouTube-based Video campaigns. You can use scripts to work with existing video campaigns, create and manage ad groups, ads, and targeting within those campaigns, and run reports. However, you can't use scripts to create video campaigns or upload new video media.

Retrieving your video campaigns and ad groups

Video campaigns are available through the videoCampaigns collection of an AdWordsApp object. You can retrieve them as you would normally retrieve campaigns in scripts:

var campaignName = "My first video campaign";

var campaignIterator = AdWordsApp.videoCampaigns()
    .withCondition("CampaignName = '" + campaignName + "'")
    .get();

while (campaignIterator.hasNext()) {
  var campaign = campaignIterator.next();
  ...
}

Once you've retrieved a campaign, you can get its ad groups in a similar manner:

var adGroupIterator = campaign.videoAdGroups()
    .withCondition("AdGroupName = '" + adGroupName + "'")
    .get();

while (adGroupIterator.hasNext()) {
  var adGroup = adGroupIterator.next();
  ...
}

Alternatively, you can use the AdWordsApp.videoAdGroups() method:

var adGroupIterator = AdWordsApp.videoAdGroups()
    .withCondition("CampaignName = '" + campaignName +
        "' and AdGroupName = '" + adGroupName + "'")
    .get();

while (adGroupIterator.hasNext()) {
  var adGroup = adGroupIterator.next();
  ...
}

Working with video ads

AdWords scripts allow you to retrieve your video ads using the videoAds() method of the VideoAdGroup. You can create new video ads using the newVideoAd() method of VideoAdGroup. There are two types of video ads supported in Scripts today: In-Stream and video discovery (previously known as In-Display). When creating a new ad, you would use either the inStreamAdBuilder() or the videoDiscoveryAdBuilder() method chained after newVideoAd().

In-stream video ads can play before, during, or after other videos, giving users the option to skip after a specified time. Video discovery ads appear on the display network and various YouTube pages and the video will only play if a user actively clicks on the ad thumbnail first. For complete details on each of these ad types, see the help center article on TrueView video ad formats.

Video targeting

There are two different types of relevant targeting for video campaigns. The VideoCampaignTargeting represents any targeting that is done at the account level for video campaigns in general, and is accessed using AdWordsApp.videoCampaignTargeting(). This cannot be modified via scripts, but can be viewed.

The other type of targeting lets you specify criteria for video campaigns and video ad groups individually. This can be accessed via the videoTargeting() method on the campaign or ad group. This provides access to selectors and builders for both positive and negative criteria for all types applicable to that level of targeting. The AdWordsApp.videoTargeting() method also exists to view criteria at the account level, and includes a different set of criteria from AdWordsApp.videoCampaignTargeting(). Like the VideoCampaignTargeting, you cannot manage these criteria with scripts.

For example, if you want to exclude a specific placement in a campaign:

videoCampaign.videoTargeting().newPlacementBuilder()
    .withUrl("http://www.example.com")
    .exclude();

Criteria for demographics (age, gender) work a little differently than the other criteria types. When a new ad group is created, criteria for each possible age and gender value are created automatically, and that ad group targets all of them. You can exclude a demographic by fetching the existing targeting and calling the exclude() method on it, and you can re-include an excluded demographic by finding the existing exclusion targeting and calling include().

For example, if you want to exclude a specific gender from an ad group:

var videoGenderIterator = videoAdGroup.videoTargeting()
    .videoGenders()
    .withCondition('GenderType = "GENDER_MALE"')
    .get();
if(videoGenderIterator.hasNext()) {
  var videoGender = videoGenderIterator.next();
  videoGender.exclude();
}

Send feedback about...

AdWords Scripts
AdWords Scripts
Need help? Visit our support page.