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
if (typeof googletag != 'undefined') {
// We have to reload the tags after positioning otherwise they will not display
// due to Google DFP policies.
googletag.pubads().refresh();
}
after the ad was moved. This should revive the ad display.