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.
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.
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.
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>
I just added a like button to my blogger, first it didn't work, but now it does,but it shows on all the pages I created on blogger Including the Contact Page http://scheissemag.blogspot.com/p/contact.html, which bothers me and I want to hide it or remove the div.
For the button code I use this one : (which I installed after <div class='post-footer-line post-footer-line2'/> )
<div>
<div id='fb-root'/>
<script>
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/fr_FR/all.js#xfbml=1';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<fb:like action='like' colorscheme='light' expr:href='data:post.url' font='arial' layout='standard' send='false' show_faces='false'/> </div>
I tried to remove with the code I found in this website after searching :
<div id="fr-root"> (I tired LikeDiv too)
my div
</div>
<script>
{
// Remove the element from the dom
var Node1 = document.getElementById('likeDiv');
Node1.removeChild(Node1.childNodes[0]);
}
</script>
But it's always there !
Instead of removing it, can you just set its visible property to FALSE?