Reply to comment

Fix empty DFP iframes on responsive websites due to illegal repositioning

Today I'd like to share a recent problem we had in a Drupal project where we were using dfp.module.

We were wondering that from time to time DFP ads were disappearing on some positions.

Moving ads parents containers is the reason

After some investigations we found out that the reason was one of the advertisement's parents containers moving around via JavaScript / jQuery.

We used $.append() to move the container for some screen sizes. But the advertisement within the container recognizes this and clears all its content. As I found out moving the container is not allowed by DFP.

So what can you do to fix this?

First of all ensure that the ad is properly displayed without moving (appending / prepending) the container around. Otherwise you might have over problems (use ?googfc appended to the URL to analyse the reasons using the Google Publisher Console)
If moving the app kills display, then you might switch to the asynchronous mode of DFP ads and execute

  1. if (typeof googletag != 'undefined') {
  2.   // We have to reload the tags after positioning otherwise they will not display
  3.   // due to Google DFP policies.
  4.   googletag.pubads().refresh();
  5. }

after the ad was moved. This should revive the ad display.


The content of this field is kept private and will not be shown publicly.

More information about formatting options