Skip to content

Instantly share code, notes, and snippets.

@kipparker
Last active August 29, 2015 13:57
Show Gist options
  • Save kipparker/9837744 to your computer and use it in GitHub Desktop.
Save kipparker/9837744 to your computer and use it in GitHub Desktop.
Standard library responsive.
<script type="text/javascript" charset="utf-8">
var gptAdSlots = [];
googletag.cmd.push(function() {
// Define a size mapping object. The first parameter to addSize is
// a viewport size, while the second is a list of allowed ad sizes.
var mapping = googletag.sizeMapping().
addSize([940, 200], [160, 600]).
addSize([0,0], []).build();
// Define the GPT slot
gptAdSlots[0] = googletag.defineSlot('/6355419/travel', [160, 600], 'wideskyleft').
defineSizeMapping(mapping).
addService(googletag.pubads());
googletag.pubads().setTargeting("test","responsive");
// Start ad fetching
googletag.enableServices();
googletag.cmd.push(function() {
googletag.display('wideskyleft');
});
});
reloadAds: function(){
googletag.cmd.push(function() {
googletag.pubads().refresh([gptAdSlots[0]]);
});
};
//reload ads on window resize, using jquery.throttle
$(window).resize( $.throttle( 250, reloadAds ) );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment