GPT - ads with key values ​​displayed in key slots of advertisements

I installed ad units and key values ​​in DFP. I created a site with the following code based on Google 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 appear (which do not have key values ​​assigned, but target all ad units). I came across this question for a while and cannot understand why setTargeting does not seem to work properly to save inappropriate ads from an ad slot with key values.

+2
source share
1 answer

, ROS . Google DFP setTargeting, .

, , ROS , "" "", ROS .

+1

Source: https://habr.com/ru/post/1686129/


All Articles