I have put the following code from adsense in a block with full html filter :

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- newad -->
<ins class="adsbygoogle"
(adsbygoogle = window.adsbygoogle || []).push({});

But I dont see the proper ads , The message comes with style :"display etc.. and some ads in very unformatted fashion . Is there some other way to put adsense code in drupal 7 ?

thanks for any help in this

2 Answers 2


full html isn't always enough to provide the necessary access. go to /admin/config/content/formats and create a new format (I call mine 'Unaltered') with the following setup (make sure to restrict it to admin ONLY):

This will allow you to perform inline js, etc within a block, without requiring a new module. Also, make sure the style listed in the js you include matches the size of the block (or more accurately, that the block matches the size of ad you want to show), or you will have strange layouts where the ad doesn't fit the container.

enter image description here

  • Please keep your screenshots under 630px here, for readability. Yes, sometimes it is not possible, but here so much white on the right side serves no purpose, and we could use a screenshot we could actually read without playing with new windows, "show image" etc. Also, it seems this would not allow him to "perform inline php", like you say. If it would, you would get -1 from me, as any answer suggesting PHP in any place other than theme or module.
    – Mołot
    Oct 28, 2014 at 12:20
  • @molot - it was a typo... calm down.
    – Geoff
    Oct 28, 2014 at 12:26
  • I am calm, you didn't get that downvote, right? But it's easy to get prejudiced against eval() once you have to spend long hours fixing site another developer opened to attacks by enabling PHP module and not enabling ModSecurity. Of course I got paid, and paid well, but anyway, situations like that happens too often, and amount of question you can find here by searching for "hacked" is scary.
    – Mołot
    Oct 28, 2014 at 12:32

As usual, there is AdSense module developed to take care of it.

This module provides web content providers with the means to earn revenue from visitors by displaying ads from Google AdSense™ advertising service on their sites.

Why should you use it:

  • The module provides easy-to-use ad blocks.
  • Provides simple controls for troubleshooting the ads before going live with the site.

List trimmed by me, of course.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.