砌体和无限滚动和谷歌DFP广告回调

Masonry and Infinite Scroll and Google DFP Advertising Callback

本文关键字:DFP 回调 滚动 无限 谷歌      更新时间:2023-09-26

我希望有人能帮助我。我使用谷歌DFP广告服务器在我的网站上提供一些广告。我还使用了Infinite Scroll和砌体。

我使用JQuery DFP脚本https://github.com/coop182/jquery.dfp.js/blob/master/jquery.dfp.js为DFP广告服务。我试图让添加显示在无限滚动,但广告没有被触发。

我已经创建了以下脚本文件,以适应回调,在页面的砌体加载…

下面的脚本调用(谷歌分析脚本)到无限滚动生成的页面

`function (newElements) {
    infscrPageview++;
     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),  =s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('send', {  'hitType': 'pageview',  'page': window.location + infscrPageview +'/',  'title': 'category/page/' + infscrPageview});`

和这部分激活社会媒体按钮…

var el = document.getElementById('.rtsocial-container');
    if (typeof gapi !== "undefined") {
        gapi.plusone.go(el);
    }
    if (typeof FB !== "undefined") {
        FB.XFBML.parse(el);
        /*FB.XFBML.parse();*/
    }
    if (typeof twttr !== "undefined") {
        twttr.widgets.load();
    }
    $container.masonry('appended', $newElems, true);
    });

如何创建回调/追加函数来激活无限滚动页面中的DFP广告?

任何帮助将不胜感激!

您可以查看我正在创建实现的页面http://3d-car-shows.com/category/motorcycle/!

好的,我已经找到了解决方案,将这行$.dfp('xxxxxx');添加到上面的脚本中…

if 
    (typeof twttr !== "undefined") {
            twttr.widgets.load();
        }

和在jquery.dfp.js文件中,我已经将值enableSingleRequest: false,从true设置为false,现在它100%工作

希望这能帮助到有类似问题的人!