DoubleClick for Publishers "Ad unit did not render." - google-dfp

As I am completely newbie this issue will be probably an easy one for others.
My ads are not displayed on the web (various banners, multiple places, none shown).
On the www.motoraport.pl/stacje I expect 2 banners to be displayed on the right, but the slots are empty.
When debugging I get an info like
MRPrawa1
Slot size: 300x250Format: DivService: DFP
Ad unit did not fetch.
Ad unit did not render.
Ad fetch count: 1
Iframe type: none
Warnings:
Ad unit failed to fetch.
-or-
MRPrawa1
Slot size: 300x250Format: DivService: DFP
251 ms to fetch creative
Ad unit did not render.
Ad fetch count: 1
Iframe type: none
However if I click in the debug console Open Creative in New Window I see the banner images.
I thought there could have been a code mess up so I created simple localhost page
<!DOCTYPE html>
<html>
<head>
<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);
})();
googletag.cmd.push(function() {
googletag.defineSlot('/19844765/MRPrawa1', [300, 250], 'div-gpt-ad-1450140062768-3').addService(googletag.pubads());
googletag.defineSlot('/19844765/MRPrawa2', [300, 250], 'div-gpt-ad-1450140062768-4').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().enableSyncRendering();
googletag.enableServices();
});
</script>
</head>
<body>
<!-- MRPrawa1 -->
<!-- /19844765/MRPrawa1 -->
<div id='div-gpt-ad-1450140062768-3' style='height:250px; width:300px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-3'); });
</script>
</div>
<!-- /19844765/MRPrawa2 -->
<div id='div-gpt-ad-1450140062768-4' style='height:250px; width:300px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1450140062768-4'); });
</script>
</div>
</body>
</html>
But the problem remains. Anybody could help?

After a couple days of pissing in the wind I accidentally discovered that all ad slots that are declared in <head/> must be implemented in <body/>.
In my case there were primarily 5 slots declared in head and 1-2 used in body depending on page.
Somehow this caused that all ads came up blank.
I hope this will help others to get through embedding DFP ads.

Related

Add DFP DoubleClick inside a Facebook Instant article

How can I add an DFP ad inside a Facebook Instant article? I use the DoubleClick service.
I need to know an example of what should I add inside the 'figure':
<figure class="op-ad">
<!-- Use this for your ads -->
<iframe src="https://www.adserver.com/ss;adtype=banner320x50" height="50" width="320"></iframe>
</figure>
Thanks
I recommend using Doubleclick's GPT tag but with the caveat of placing the whole ad tag within the iFrame (as opposed to making calls to the head element). An example can be found below:
<figure class="op-ad"><iframe height=“250" style="border:0;margin:0;padding:0;" width="300”>
<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” (http://www.googletagservices.com/tag/js/gpt.js%E2%80%9D);
var node = document.getElementsByTagName(“script”)[0];
node.parentNode.insertBefore(gads, node);
})();
</script><script type="text/javascript">
googletag.cmd.push(function() {
googletag.defineSlot("/1234/travel/asia/food", [[300, 250]], "div-gpt-ad-123456789-1").addService(googletag.pubads()).setTargeting(“abc”, “xyz”).setTargeting(“123”, “456”);
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
</script><div id="div-gpt-ad-123456789-1">
<script type="text/javascript">
googletag.cmd.push(function() { googletag.display(“div-gpt-ad-123456789-1”); });
</script></div>
</iframe>
</figure>
AdPlugg allows you to do this. Your code above would become:
<figure class="op-ad">
<!-- Use this for your ads -->
<iframe src="http://www.adplugg.com/serve/<your_adplugg_access_code>/html/1.1/index.html?zn=fb_zone_1" height="50" width="320"></iframe>
</figure>
Then from inside your AdPlugg account, you would drop in your tag from Google. You could also then rotate in affiliate network ads, your own direct buy ads, etc.
That should be all that you need but if you want, you can read more about how to set up Facebook Instant Article ads in a blog that I posted: Facebook Instant Article Ads.
Disclaimer: I work for AdPlugg.
Prepare a DFP integration static HTML file by using GPT like seen below:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}</style>
<script type="text/javascript">
(function() {
var useSSL = 'https:' == document.location.protocol;
var src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
})();
</script>
<script type="text/javascript">
googletag.defineSlot('/YOUR_DFP_ACCOUNT_NUMBER/YOUR_ADUNIT_CODE', [300, 250], 'div-gpt-ad-1459514019072-0').addService(googletag.pubads());
googletag.enableServices();
</script>
</head>
<body>
<div id="div-gpt-ad-1459514019072-0">
<script type="text/javascript">
googletag.display('div-gpt-ad-1459514019072-0');
</script>
</div>
</body>
</html>
Save and host it somewhere like http://example.com/fbia-banner.html
And now call this URL by using Facebook Instant Article (FBIA) ad syntax :
<figure class="op-ad">
<iframe height="250" width="300" src="http://example.com/fbia-banner.html"></iframe>
</figure>
And test whole page code by using FBIA test tools.
Notes:
Using a proxy file like this solution isnot the best solution, it would be better if there was a direct DFP URL to serve. I tried DFP simplified url tags but it's not suitable to use in FBIA
Facebook complains about having "width" and "height" attributes on iframe tags, you should remove them.

Google adsense awlays displays blank

I create an ad unit with my google adsense account,and add the sync code piece into my page:
<script type="text/javascript">
google_ad_client = "ca-pub-2512354990153831";
google_ad_slot = "4650942105";
google_ad_width = 728;
google_ad_height = 90;
</script>
<!-- index_top_ad_01 -->
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>
But it always return empty "",you can view the site。
Can someone help me?

google dfp does not show up ads continuosuly

I have created a ad unit in google dfp and line item/order with clicks of 10000 with 3 days campaign. For one day it was showing the ad only once in a while in ad slot in my webpage. After that the rate increased but still sometimes it may show the ad slot on my webpage empty. Does anybody know how to setup or do some scripting so that once it starts showing up, it will show up continuously for anybody who visits the webpage until the campaign or that targets are achieved. On web there are discussions about auto-collapse of divs when ad is not fetched, but I want to keep the space for an ad continuously, it should not appear empty if ad is not fetched.
Code in website looks like this:
<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Widgets Magazine</title>
<style type="text/css" media="screen">
</style>
<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>
</head>
<body>
<!-- Anywhere -->
<div id='div-gpt-ad-xxx-0' style='width:250px; height:250px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-xxx-0'); });
</script>
</div>
</body>
Thanks for the help.
Your Javascript code most likely is okay. The problem is on the server side, in the settings of your line item.
Based on the number of clicks and the length of the campaign you have configured, DfP will estimate the delivery speed to evenly distribute the ad impressions and/or clicks for the duration of the campaign.
In order to always serve an ad, you either:
create a new line item of type network or similar where you can configure to fulfill 100% of the remaining impressions (see Line item types and their delivery priorities), or
set the delivery speed of your line item to as fast as possible (see Change the delivery speed of a line item)
Note that DfP will completely stop serving the campaign once the delivery target (the number of clicks or ad impressions) has been reached.

How to get ads to refresh using googletag.pubads().refresh()?

I have an ad and a link in a page like so:
<!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>
The first time I click the link, the ad refreshes. All other times nothing happens. Even just calling the refresh() method in Firebug etc does nothing after the first time.
What's wrong with the above?
According to https://support.google.com/dfp_premium/answer/4578089 the refresh function takes a parameter of an array of adSlots:
googletag.pubads().refresh([gptAdSlots[0], gptAdSlots[1]]);
Does that change the behaviour for you?
Failing that, I would recommend enabling the Google Publisher Console by adding the google_console or googfc parameter to your querystring (see https://support.google.com/dfp_sb/answer/181070?hl=en for details), and checking for errors
This is the source of the problem
googletag.pubads().enableSingleRequest();
Stop using singlerequest mode and you can call googletag.pubads().refresh() with no problem. Not managed to find any documentation explaining this.
Try it:
googletag.pubads().refresh(null, {changeCorrelator: false});
From https://developers.google.com/doubleclick-gpt/reference:
Fetches and displays new ads for specific or all slots on the page. Works only in asynchronous rendering mode.
For proper behavior across all browsers, calling refresh must be preceded by a call to display the ad slot. If the call to display is omitted, refresh may behave unexpectedly. If desired, the disableInitialLoad method can be used to stop display from fetching an ad.
and:
Configuration options associated with this refresh call. changeCorrelator specifies whether or not a new correlator is to be generated for fetching ads. Our ad servers maintain this correlator value briefly (currently for 30 seconds, but subject to change), such that requests with the same correlator received close together will be considered a single page view. By default a new correlator is generated for every refresh.
I hope it helped a little at least.
I can't see any answer to the issue right now. I encountered the same problem in the site I am currently working and lucky enough to accidentally solve the issue by adding $(window).load(function(){ }); in the javascript code.
You need to define slot in both the parts:
<script src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
</script>
<script>
googletag.cmd.push(function() {
slot1 = googletag.defineSlot('/xxxx/suihgdwiuhdwiu', [728, 90], 'div-gpt- ad-xxxxxxx-0').
setTargeting("test", "refresh").
addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
And:
<div id='div-gpt-ad-xxxxxxxxx-0' class="adsbygoogle">
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-xxxxxxxx-0'); });
setInterval(function(){googletag.pubads().refresh([slot1]);}, 60000);
</script>
</div>
</div>
I don't think you have got your ad unit definition quite right.
Try:
<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>
Obviously to get this working you will need to change /1234567/Home_Top_Leaderboard_728x90 to the correct values.
For me the solution was:
googletag.pubads().updateCorrelator();
googletag.pubads().refresh();
If you want to make the ad slot are refresh perhaps may using this method,
<!-- header script -->
<script async='true' src='https://securepubads.g.doubleclick.net/tag/js/gpt.js'></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var REFRESH_KEY='refresh';
var REFRESH_VALUE='true';
</script>
<script>
googletag.cmd.push(function() {
var slot_bottomframe = googletag.defineSlot('/1001256/Home_Top_Leaderboard_728x90', [728,90], 'div-gpt-ad-1342320102476-72');
slot_leaderboard.setTargeting('pos',['leaderboard']);
slot_leaderboard.setTargeting(REFRESH_KEY,REFRESH_VALUE);
slot_leaderboard.addService(googletag.pubads());
var SECOND = 60;
googletag.pubads().addEventListener('impressionViewable',function(event) {
var slot=event.slot;
if(slot.getTargeting(REFRESH_KEY).indexOf(REFRESH_VALUE)>-1) {
setTimeout(function() {
googletag.pubads().refresh([slot]);
}, SECOND*1000);
}
});
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
</script>

Google Analytics code error implementing in .asp file

I am implementing Google Analytics in a form page.
The problem comes after the form is sent by a user.
In the form landing page, the GA tracking code is partly duplicated in the body, creating duplicated stats for the landing page.
I've checked my asp file and have no clue on what I could be doing wrong.
I hope someone can point me on the right direction, thanks in advance.
<head>
<%if Request.QueryString("enviado") = 1 then%>
<script type="text/javascript">
var google_conversion_id = 97885866;
var google_conversion_language = "es";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "BNPUCI6xqQIQ-ofj0gM";
var google_conversion_value = 0;
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http:www.googleadservices.com/pagead/conversion/978895866/?label=BNPUCI6xqQIQ-ofj0gM&guid=ON&script=0"/>
</div>
</noscript>
<script language="javascript" type="text/javascript">
window.ysm_customData = new Object();
window.ysm_customData.conversion = "transId=,currency=,amount=";
var ysm_accountid = "1FJ1MOC128JN2MQEDCC45EREVMC";
document.write("<SCR" + "IPT language='JavaScript' type='text/javascript'" + "SRC=//" + "srv3.wa.marketingsolutions.yahoo.com" + "/script/ScriptServlet" + "?aid=" + ysm_accountid + ">
</SCR" +"IPT>");
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount, 'UA-10880766-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<%end if%>
</head>
I'm a little bit late, but maybe this helps other people as well.
When I understand this correct you are referring to the fact, that the GoogleAnalytics Tracking is fired twice.
If yes, I also had a similar problem on my page. The problem however did only occur in Firefox and Chrome, but not in Internet Explorer.
This problem was in my case related to a empty src tag in my code. In Firefox and Chrome "" means "this URI" and therefore my tracking was fired twice.
I could fix that by removing the yahoo pixel in my code.
You can read also: here for more info.