我们有一个正在运行的项目,其中客户要求实施Google DoubleClick for Advertising。客户已向我们提供了DFA的示例代码,我们已尝试在类别页面中实施这些代码,但它根本不起作用。任何人都可以看看下面的内容,让我知道什么可能是AD没有显示,只是错误。
HEADER PART :
<script type='text/javascript'>
vargoogletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
varuseSSL = '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.defineSlot('/2408346/Asociacion_bottom', [728, 90], 'div-gpt-ad-1340819095858-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
文件正文部分:
<div id='div-gpt-ad-1340819095858-0' style='width:728px; height:90px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1340819095858-0'); });
</script>
</div>
抛出错误而根本不显示任何广告(即使在所有浏览器中):
错误列表:
googletag is not defined
[Break On This Error] vargoogletag = googletag || {};
googletag is not defined
[Break On This Error] googletag.cmd.push(function() {
googletag is not defined
[Break On This Error] googletag.cmd.push(function() { goog...y('div-gpt-ad-1340819095858-0'); });
答案 0 :(得分:5)
您的脚本中似乎有一些语法错误。
这一行:
vargoogletag = googletag || {};
应该是:
var googletag = googletag || {};
varuseSSL也应该有一个空格... var useSSL
试试这个:
<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">
googletag.cmd.push(function() {
googletag.defineSlot('/2408346/Asociacion_bottom', [728, 90], 'div-gpt-ad-1340819095858-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<div id='div-gpt-ad-1340819095858-0' style='width:728px; height:90px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1340819095858-0'); });
</script>
</div>
</body>
</html>
答案 1 :(得分:0)
除了拼写错误之外,您可能还有一个与广告冲突的minify插件。