2

次のようなページに広告とリンクがあります。

<!DOCTYPE html>
<head profile="http://www.w3.org/1999/xhtml/vocab">
<title>DPT - Asynchronous + Single Rest Architecture</title>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <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'>
    googletag.cmd.push(function() {
    googletag.pubads().enableAsyncRendering();
    googletag.defineSlot('/1001256/Home_Top_Leaderboard_728x90', [728, 90], 'div-gpt-ad-1342320102476-72').addService(googletag.pubads());
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
    });
</script>
</head>
<body>
    <div id="div-gpt-ad-1342320102476-72" style="width:728px; height:90px;">
      <script type="text/javascript">
        googletag.cmd.push(function() { googletag.display('div-gpt-ad-1342320102476-72'); });
      </script>
    </div>
    <a id="refresh" href="#">Refresh ad</a>
    <script type='text/javascript'>
    (function ($) {
        $('#refresh').click(function() {
         googletag.cmd.push(googletag.pubads().refresh());
        return false;
        });
    })(jQuery);
    </script>
</body>
</html> 

リンクを初めてクリックすると、広告が更新されます。それ以外の場合は、何も起こりません。Firebug などで refresh() メソッドを呼び出すだけでも、初回以降は何もしません。

上記の何が問題になっていますか?

4

8 に答える 8

4

これが問題の原因です

googletag.pubads().enableSingleRequest();

singlerequest モードの使用をやめれば、問題なく googletag.pubads().refresh() を呼び出すことができます。これを説明するドキュメントを見つけることができませんでした。

于 2015-01-13T23:00:52.507 に答える
0

私にとっての解決策は次のとおりです。 googletag.pubads().updateCorrelator(); googletag.pubads().refresh();

于 2016-02-26T19:46:56.923 に答える
0

広告ユニットの定義が正しくないと思います。

試す:

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

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

    <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">
        googletag.cmd.push(function() {
        googletag.pubads().enableAsyncRendering();
        googletag.defineSlot('/1234567/Home_Top_Leaderboard_728x90', [728, 90], 'div-gpt-ad-1342320102476-72').addService(googletag.pubads());
        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
        });
    </script>

</head>
<body>

    <div id='div-gpt-ad-1342320102476-72' style='width:728px; height:90px;'>
        <script type='text/javascript'>
                googletag.cmd.push(function() { googletag.display('div-gpt-ad-1342320102476-72'); });
        </script>
    </div>

    <a id="refresh" href="#">Refresh ad</a>

    <script type='text/javascript'>
        (function ($) {
            $('#refresh').click(function() {
                googletag.cmd.push(googletag.pubads().refresh());
                return false;
            });
        })(jQuery);
    </script>

</body>
</html>

明らかにこれを機能させるには、/1234567/Home_Top_Leaderboard_728x90 を正しい値に変更する必要があります。

于 2012-08-29T08:13:15.547 に答える