Setting Ads without using an Ad Server

ProductEdition
Video CloudProfessional, Enterprise

This document describes how to integrate Video Cloud players with ads. It is intended for Video Cloud Pro or Enterprise publishers who have built a custom ad library or are using a product like Google AdSense for Video to render all player ads. See Brightcove Ad Integrations for a summary of other available ad integration approaches.

This functionality is not available for Video Cloud Express customers. If you are interested in upgrading your Video Cloud account, please contact Brightcove for more information.

Have you created a custom ad SWF to use in your player? Perhaps you've developed around an ad library and want to deliver this mini-application to your player without using an ad server. Or maybe you want to use one of Video Cloud's ad library implementations (like Google AdSense, YouMe, Tremor Media, etc.) in your player without going through the hoops of creating ad format XML, uploading the XML to an ad server, and actually trafficking the ad XML to your player?

The disadvantage of delivering ads without using an ad server is that you lose impression tracking and, therefore, lose valuable reporting data. There are some instances, though, where this data and the other features of an ad server aren't as important as getting started quickly and easily.

There are two  simple ways to get ads to render in your player without using an ad server. The first way is to set your player's ad server URL to a hosted ad XML file. This solution is the most simple but is limited, since the same ad will be returned for every ad call the player makes. The second solution is to create a custom ad translator that uses key/value pairs set in the Video Cloud Studio Advertising module to deliver whatever ad you would like. This means you have the flexibility to deliver different ads depending on the insertion point of the ad call. 

These are both great solutions if you have built a custom ad library or if you are using a product like Google AdSense for Video to render all of your player ads. Let's walk through two quick examples of how to easily set a video player to use Google AdSense without an ad server, first using the simple hosted ad XML solution and, second, using the ad translator solution. See Google AdSense for Video Integration for more information about Brightcove's integration of Google AdSense for Video.

Using a hosted Ad XML file

Do you have one ad that you want to play every time the player makes an ad call? This simple hosted XML solution is for you. First, use the Video Cloud Publishing module to create any type of player (Screenshot 1) and assign ad-enabled videos to your player using the Video Cloud Media module (Screenshot 2).

Next, let's create the example Google ad format XML. Create an XML file containing the following and upload it to your server. Remember that to use Google AdSense in your live players, you must contact Google to get your own account and publisher ID. The information used in the XML below is only for testing. For more information about supported Brightcove ad formats, see Supported Ad Formats and Format Codes.

<adSwf version="1" >
   <!-- path to Google swf -->
   <adSwfURL>[http://admin.brightcove.com/adswf/Google.swf]</adSwfURL>
   
   <-- The publisher's AFV client ID (provided by AdSense). -->
   <videoPublisherId>some-test-id</videoPublisherId>
   
   <!-- The full URL of an HTML page that describes the video. -->
   <videoDescriptionUrl>[http://www.eepybird.com/test.html]</videoDescriptionUrl>
   
   <!-- An array of strings representing AdSense targeting/reporting channel IDs.
    The channel IDs may only contain numbers, letters, underscores, and hyphens
    (no spaces or other special characters), and they must match the channel IDs created
    in your AFV account by your TAM. Up to 5 channels may be passed in per ad request. -->
   <channels>sports, entertainment</channels>
  
   <!-- The type of ad to request. This parameter should be set to "text_overlay" for
    text overlay ads only, "overlay" for text overlay and InVideo graphical overlay
    ads, or "fullscreen" for fullscreen text and image endcap ads. -->
   <adType>text_overlay</adType>
  
   <!-- Specifies whether this is a test implementation or not. Possible values are
   "on" or "off". If set to "on," impressions and clicks will not be recorded
    in your account. This parameter MUST be used during testing. -->
   <adtest>on</adtest>
   </adSwf>
  

After you have uploaded your XML to your web server, go ahead and set your player's ad policy using the Video Cloud Advertising module (Screenshot 3). Set this player to have a pre-roll insertion point and title-based ad policy. Set your player's ad server URL to be the URL of your hosted ad format XML file, remembering to include a ? at the end of the ad server URL. Make sure that ads are turned on in your player.

Now, launch your player and click play to see your Google ad render.

Using a custom ad translator

Since Google AdSense for Video allows several different ad formats to be displayed in your player, you might want to dynamically change which type of ad format is rendered depending on your insertion point (for example, pre-roll ad, mid-roll ad, etc.). For example, you might want an overlay text ad to show up at the pre-roll insertion point but an overlay-to-video ad to show up at a midroll insertion point. The custom translator solution can easily solve this problem.

We will go over a simple example of a custom ad translator in this article.  We have another article that has a more full-featured ad translator.   See Example of a Built-in Ad Server for the source and SWF to an ad translator which can be used to serve video ads or ad SWFs.

We can use the same player you created above to test out the custom ad translator solution. First, though, let's write this custom translator. See Developing Ad Translators to learn more about creating custom ad translators. Use that article to set up your development environment and get the bc_ads.swc that will allow you to compile your translator. Once you have set up your development environment, use the code snippet below as your ad translator class. Just copy and paste the code below into your ActionScript file.

You'll notice that the ad format XML has been hardcoded into this translator and then passed to the player, instead of being hosted as an XML file on a server. The difference, though, is that you can program which ad type you would like delivered using Video Cloud's Advertising module. Go ahead and compile your translator and host it on your own server. Then, we'll continue setting up your player to use your translator.

package {
    import com.brightcove.fl.advertising.AdContext;
    import com.brightcove.fl.advertising.translation.AdTranslation;
    import com.brightcove.fl.advertising.translation.TranslationURLLoader;
	
    /**
    * An example translator that loads the Google Ad Swf without using an ad server.
    *
    * In order to compile this class, you must have bc_ads.swc in your external-library path.
    * See the ad tag translation documentation for more details.
    */
	
    public class GoogleExample extends AdTranslation {
        private var loader:TranslationURLLoader = new TranslationURLLoader();
	
        public function GoogleExample() {
            // The translator is loaded when the player is loaded.
            trace("Ad translator has been loaded.");
        }
	
       /**
        * Construct ad call and fetch the ad.
        **/
	
        override public function fetchAd(context:AdContext):void {
        // Set the ad type as an insertion key/value pair in the Advertising Module.
        // In this example, the key is entered in the pre-roll insertion as "text_overlay."
        // Other values for the google library include "overlay" or "fullscreen."
        // Making use of the key/value pairs fields in the Advertising Module
        // allow you to use the Google library throughout player load but still be
        // able to change ad type, channel, and description url metadata.
	
            var adType:String = context.insertionKeyValues as String;
	
            var googleAd:String = "<adSwf version='1'>" +
                          "<adSwfURL>http://admin.brightcove.com/adswf/Google.swf</adSwfURL>" +
                          "<videoPublisherId>ca-video-afvtest</videoPublisherId>" +
                          "<videoDescriptionUrl>http://www.eepybird.com/dcm1.html</videoDescriptionUrl>" +
                          "<channels>sports, entertainment</channels>" +
                          "<adType>" + adType + "</adType>" +
                          "<adtest>on</adtest>" +
                          "</adSwf>";
            setAdXML(new XML(googleAd));
      }
    }
}

If you look at the code above, you will see this line var adType:String = context.insertionKeyValues as String; indicating that we are pulling the ad type from the key/value pairs field in the Video Cloud Advertising module.

Use the player you created from the first example and edit it in the Advertising module (Screenshot 5). Remove the Ad Tag URL and add the URL to your custom ad translator in the "Custom" field as shown in Screenshot 5. Then, add the key "text_overlay" to the Pre-Roll Key/Value Pairs field as also shown below. This will ensure that Google text overlays will be returned to your player. Save your changes and launch your player.

As you click a video to play it, you will see the Google text ad render exactly as it did in the first ad server solution example. However, if you decided that you wanted graphic overlays instead of text overlays, it is very simple to edit the advertising policy for your player again and just type "overlay" into the Pre-Roll Key/Value Pairs field.

Setting your player to render ads has never been so easy!

Post new comment

The content of this field is kept private and will not be shown publicly.
0

Comments