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.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.

More information about formatting options

Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.