1
    <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を使用して広告キャンペーンを実行しているWebサイトに広告スロットがあります。
現在のクライアントには一連のキーワードがあります。そのため、彼自身のクリエイティブを表示できます。
最近、同じ広告スロットに掲載したい別のクライアントを登録しましたが、まったく別のキーワードセットを使用しています

質問:入力されたキーワードを検索して特定の広告キャンペーンの広告を表示できるように、上記のコードを微調整するにはどうすればよいですか?

'TargetedKey'=サインアップしたクライアントの名前
'Targetedvalue'=彼がサインアップしたキーワード。(基本的に、彼には約10個のキーワードがあり、ユーザーが私のWebサイトで検索を実行すると、「Targetedvalue」ビットを入力することができます)

ps私は過去2か月間にDFPを手に入れ、組織の広告キャンペーンを自主的に管理してきました。私もプログラミングが苦手です。

4

2 に答える 2

2

これはDFPよりもjavascriptと関係がありますが、以下ではさまざまなキーワードの組み合わせをテストできます...

次のように、URLでキーと値のカンマ区切りを使用してこのページをロードします:http: //yoursite.com/? key = test&values = test 1、test 2、test 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>
于 2012-10-11T15:00:48.907 に答える