Created
March 23, 2018 12:18
-
-
Save oscard0m/3eb21c0752c5b6cf89ebaf3e0e527357 to your computer and use it in GitHub Desktop.
HTML document to load DFP tags dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> | |
<meta charset="UTF-8"> | |
<title>DFP</title> | |
</head> | |
<body> | |
<script async="async" src="https://www.googletagservices.com/tag/js/gpt.js"></script> | |
<script> | |
var googletag = googletag || {}; | |
googletag.cmd = googletag.cmd || []; | |
</script> | |
<script> | |
function loadDFP() { | |
var placementContainerId = `adContainer${Date.now()}`; | |
var adPlacement = document.createElement('div'); | |
adPlacement.id = placementContainerId | |
document.body.appendChild(adPlacement); | |
googletag.cmd.push(function() { | |
googletag.defineSlot('/12345/marfeel/wii', [[300, 50], [320, 50]], placementContainerId) | |
.addService(googletag.pubads()) | |
.setTargeting("videogame", "Mario Kart") | |
.setTargeting("character", "Mironescu") | |
googletag.enableServices(); | |
googletag.display(placementContainerId); | |
}); | |
} | |
</script> | |
<button onClick=loadDFP()>Cargar Banner</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment