Skip to main content

Drupal not showing javascript (e.g. AdSense) in nodes or blocks?

Ok, you have a shiny new website, you have Drupal as a CMS and you have an AdSense account. The only thing you don't have is a clue about why banners are not showing up on your website, even though you copied the AdSense code verbatim into your nodes/blocks.

First of all, let me give you a fair warning: Never put bannercode directly in your content nodes. Doing so will completely undermine the idea of using a CMS in the first place and open you up to all sorts of nasty side effects like for example accidentally showing more then the allowed amount of ads in the teasers of your frontpage. You may want to read this article for some ideas on AdSense integration in Drupal.

Anyway, ignoring the warning above, what is the secret for seeing quick results? Quite easy: Your problem are the input filters. You might have had the idea of switching from "Filtered HTML" to "Full HTML" already, assuming that javascript would be allowed in full HTML mode. It is not. In order to allow javascript to pass, you have to switch the input format to "PHP code". Be careful with this though, as it (who would have guessed) also allows the execution of server side scripts and hence is another reason not to put AdSense code directly into content nodes.