Presented by Joe Hohertz / @joehohertz
Tell me a bit about yourself, and what you would like to come away with today from this session.
gads.async = true; // or set to false
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true; // can disable to LOAD sync, but use async mode
gads.type = 'text/javascript';
gads.src = '//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);
})();
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var useSSL = 'https:' == document.location.protocol;
var src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
document.write(' ');
})();
googletag.pubads().set("adsense_background_color", "FFFFFF");
// define an ad slot.
googletag.cmd.push(function() {
// parameters:
// string: '/network/zone'
// array: one or more pairs of [x,y] dimensions
// string: the id of the div containing the ad
var adSlot = googletag.defineSlot(
'/6062/video-demo-preload',
[728, 90],
'adSlot1Div');
// can set these per-ad or as page-wide
adSlot.setTargeting("gender", "male")
// if this is to be a companion ad, add it to the companion service
// adSlot.addService(googletag.companionAds());
adSlot.addService(googletag.pubads());
});
// define as many more slots as needed
googletag.cmd.push(function() {
googletag.pubads().setTargeting("topic","basketball");
googletag.pubads().setTargeting("tags",["basketball", "raptors"]);
});
googletag.companionAds().setRefreshUnfilledSlots(true);
googletag.pubads().enableSyncRendering();
googletag.pubads().enableSingleRequest();
googletag.enableServices();
googletag.cmd.push(function() {
var adSlot = googletag.defineSlot(
'/6062/video-demo-preload',
[728, 90],
'adSlot1Div');
adSlot.addService(googletag.companionAds());
adSlot.addService(googletag.pubads());
// new parts here and below:
adSlot.addService(googletag.content());
googletag.content().setContent(adSlot,
'Custom content in ad slot.
'
);
});
url = u "?google_force_console=1"
// still doing an "ord" like value here
var correlator = Math.round(Math.random() * 100000000);
// parameters
var video_size = "400x300";
var companion_sizes = "300x250,728x90";
var video_zone = "/6062/video-demo";
// build the URL
var vastURL = "http://pubads.g.doubleclick.net/gampad/ads" +
'?sz=' + video_size +
'&iu=' + encodeURIComponent(video_size) +
'&ciu_szs=' + encodeURIComponent(companion_sizes) +
'&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1' +
'&url=' + encodeURIComponent(window.top.location.href) +
'&correlator=' + correlator;