Google Responsive Ads Not Working On Drupal

Author:
phil
Created:
Thursday, December 22nd, 2016
Last Updated:
Monday, April 16th, 2018

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


While this post might point someone in the right direction who isn't using Drupal, this is specifically designed to help folks using Drupal with Google Ads.

The Problem

When trying to use responsive Adsense ads, they only show up as a 303x80 size, regardless of the preceding container size.

The Fix

First and foremost, Googles Responsive ads will ONLY work based on the PARENT container. No exceptions. While the documentation clearly outlines this, you need to be aware that CMS software such as Drupal, will create a parent <p> container before the ad code and after any custom container you "think" is the parent container.

Drupals format filter has an option to "Convert line breaks into HTML (i.e. and )". This is the culprit for causing your ads not to be responsive. Even though you may have a "parent" container with some styling, Drupal is injecting that extra paragraph tag into the mix, right before the adsense code.

The best way to get around it is to create a block or paragraph or field that can be contained within itself to ONLY be allowed to issue a custom text format. I create a new text format called Adsense HTML and I disable all processing on that format except for the Adsense modules processor called: Adsense tag.

Once you can isolate your code so that there isn't any hidden tags being injected to the source, your responsive ads should start showing up.

Post Comment