Skip to content

Instantly share code, notes, and snippets.

@Rooke
Last active April 13, 2017 18:26
Show Gist options
  • Save Rooke/cab8b87356b6e1259dc51cae8aca8292 to your computer and use it in GitHub Desktop.
Save Rooke/cab8b87356b6e1259dc51cae8aca8292 to your computer and use it in GitHub Desktop.
A canonical DFP implementation
<!DOCTYPE html>
<html>
<head>
<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
</script>
<script>
googletag.cmd.push(function() {
googletag.defineSlot('/123456789/yoursite_lead_1', [728, 90], 'div-gpt-ad-1489999001534-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<script src="//tags-cdn.deployads.com/a/site.com.js" async ></script>
<!-- Add a timeout function to allow ads to show if the above Javascript fails to load after 2.0s -->
<script>(function(){var a=window.googletag=window.googletag||{};a.cmd=a.cmd||[];var c=window.deployads=window.deployads||[],g=setTimeout(function(){if(!c.apiReady){c.apiTimeout=!0;c.gpt={display:function(d){a.cmd.push(function(){a.display(d)})},pubadsRefresh:function(d,b){a.cmd.push(function(){a.pubads().refresh(d,b)})},pubadsDisplay:function(d,b,e,f){a.cmd.push(function(){a.pubads().display(d,b,e,f)})}};for(var b=0;b<c.length;b++)try{c[b]()}catch(d){}}},2E3);c.push(function(){clearTimeout(g)});})();</script>
</head>
<body>
<!-- Your Page Source ... -->
<!-- /123456789/yoursite_lead_1 -->
<div id='div-gpt-ad-1489999001534-0' style='height:90px; width:728px;'>
<script>
deployads.push(function() { deployads.gpt.display('div-gpt-ad-1489999001534-0'); });
</script>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment