问题
I have set up Ad Units and Key Values in DFP. I have built the site with the following code based on Google's tutorials:
<html lang="en">
<head>
<script type="text/javascript">
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
var useSSL = "https:" == document.location.protocol;
gads.src = (useSSL ? "https:" : "http:") + "//www.googletagservices.com/tag/js/gpt.js";
var node =document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(gads, node);
})();
</script>
<script>
var sitePath = "/test-kv/parent/page"
googletag.cmd.push(function() {
var kvAdSlot =
googletag.defineSlot('/00000000' + sitePath, [300, 250], 'kvAd');
kvAdSlot.addService(googletag.pubads());
kvAdSlot.setTargeting('key', 'value');
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
</script>
</head>
<body>
<div id='kvAd'>
<script>
googletag.cmd.push(function() { googletag.display('kvAd'); });
</script>
</div>
</body>
</html>
However, when I test the page, my ROS ads (which have no key values assigned but target all ad units) are showing up. I have been messing with this for a while and cannot figure out why the setTargeting doesn't seem to be working properly to keep non targeted ads out of the key value ad slot.
回答1:
It's perfectly logical that your ROS ads are returned. Google DFP will not exclude ads based on setTargeting unless specifically defined in your line-item.
In your line-item, if you were to specify that the ROS should be shown IF "key" is not equal to "value", then the ROS ads would not be shown.
来源:https://stackoverflow.com/questions/38959582/gpt-non-key-value-ads-showing-in-key-valuse-ad-slots