DFP上的单个广告位 - 需要投放多个有针对性的广告系列

时间:2012-10-10 07:37:37

标签: ads google-dfp

    <script type='text/javascript'>
    googletag.cmd.push(function() {
    googletag.defineSlot('/11589435/serptest300x250', [300, 250], 'div-gpt-ad-1345189271658-0').addService(googletag.pubads()).setTargeting("TargetedKey","Targetedvalue");
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
    });
    </script>

我的网站上有一个广告位,目前使用Google的DFP投放广告系列 当前客户有一组关键字,因此我们可以向他展示自己的创意 最近,我们已经注册了另一个想要在同一个广告位中展示的客户,但是,对于一组不同的关键字

问题:如何调整上面的代码,以便我可以查看输入的关键字并显示特定广告系列中的广告?

&#39; TargetedKey&#39; =我们已注册的客户的名称
&#39; Targetedvalue&#39; =他已注册的关键字。 (基本上,他有大约10个关键字,当用户在我的网站上执行搜索时,我设法输入&#39; Targetedvalue&#39;位)

P.S。我在过去两个月内选择了DFP,并且一直在为我的组织自愿管理广告活动。我也不擅长编程。

2 个答案:

答案 0 :(得分:2)

这更多地与javascript相比,而不是DFP,但以下应该允许您测试不同的关键字组合...

加载此页面时,您的密钥和值逗号分隔在URL中,如下所示: http://yoursite.com/?key=test&values=test 1,测试2,测试3

<html>
<head>
    <title>DFP test</title>

    <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 type="text/javascript">

        function getParameterByName(name)
        {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if(results == null) {
                return "";
            } else {
                return decodeURIComponent(results[1].replace(/\+/g, " "));
            }
        }

        var key = getParameterByName('key');
        var values = getParameterByName('values').split(',');

        googletag.cmd.push(function() {
            slot = googletag.defineSlot('/11589435/serptest300x250', [300, 250], 'adunit').addService(googletag.pubads()).setTargeting(key,values);
            googletag.pubads().enableSingleRequest();
            googletag.enableServices();
        });
    </script>

</head>
<body>

    <div id="adunit">
        <script type='text/javascript'>
            googletag.cmd.push(function() {
                googletag.display('adunit');
            });
        </script>
    </div>

</body>
</html>

答案 1 :(得分:0)

我希望您希望根据某个目标关键字获取广告。

您可以尝试以下方式,即在settargeting()方法中传递关键字

 googletag.pubads().setTargeting('tags', 'Male'); // where Male is the target keyword
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
相关问题