Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling DFP / DoubleClick iFrames

In Google DFP (DoubleClick) you are given an ad code to put in your header and another for your body. When I apply this given ad tag / code to my website, whether its asynchronous or synchronous the ad always displays within an iframe. I'm wondering how I would disable the iFrame.

Here is the generated header code via DFP:

<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('/16569348/ad-test-1', [400, 267], 'div-gpt-ad-1362958263281-    0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>

Here is the generated body code via DFP:

<!-- ad-test-1 -->
<div id='div-gpt-ad-1362958263281-0' style='width:400px; height:267px;'>
<script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1362958263281-0'); });
</script>
</div>

Here is the jsFiddle showcasing this problem (inspect element in google chrome to see iframe):

http://jsfiddle.net/EptwH/

Again, I'd like to remove the iframe (and keep the image / ad of course)... any help would truly be appreciated. :)

like image 579
Dyck Avatar asked Mar 11 '13 03:03

Dyck


4 Answers

From DFP's website: link

When you are using Google Publisher Tags (GPT), your ads will automatically load into iframes.

like image 193
Rob M. Avatar answered Nov 18 '22 06:11

Rob M.


We had the same issue, as our goal was to add native ads directly to the host page DOM and not an IFRAME to gain full responsiveness. We came up with a solution, where we're posting the ad content string to the host page using messages. This way there is no more IFRAME.

For details please see http://insights.burda-studios.de/howto-run-fully-responsive-doubleclick-native-ads-without-iframes/

Please note, that we only run house ads using this approach, not any 3rd party ads where this could lead to unexpected behaviours.

like image 2
funkymusic Avatar answered Nov 18 '22 06:11

funkymusic


I'm working for a digital advertiser and you never should disable iFrames coming from advertising.

ADS can inclusce harmfull scripts, so best would be using Safeframe (frame using src poining to foreign origin) to prevent that.

Also many ad script use document.write, and inside their iframe they can do that without problem, would they do that on main window after document.ready that would paint your page blank.

like image 2
René Baudisch Avatar answered Nov 18 '22 06:11

René Baudisch


Google loads its ads into iframes purposely, this is by design.

This is done because it both allows your page to load faster and to have sand-boxed styles and scripts etc. The render of the page is faster because iframes enable asynchronous loading and rendering of the ad content.

It is possible to "bust" out of the iframe with your ad code if you want, so there is no real disadvantage to the ads being in an iframe, show us an example of what you are trying to do if you have run into a problem

Here is some more reading to do with this.

like image 1
Matt Cooper Avatar answered Nov 18 '22 04:11

Matt Cooper