google adsense javascript doesn't work, no ads displayed

forrestbao - September 29, 2007 - 22:39

Hi,

I had a problem on embedding Javascript into HTML content in Drupal.

I tried to create a block whose content is the Google Adsense code generated at Google Ads website.
But I found that this block didn't display anything after I enabled it and placed it on the left banner.

I also tried to publish a content containing some text with this Javascript code. But nothing was displayed, except pure text part.

Drupal Module Adsense is also tried by me. But nothing was displayed except a black border with black text "Google adsense" inside.

Can anyone tell me why the Javascript doesn't run in my content? How can I enable it?

The Google AdSense module is

rszrama - September 30, 2007 - 00:33

The Google AdSense module is actually working. It just shows the placeholder for your admin account. Logout and you should see the ads.

Regarding the JS issue, did you change the input format to full HTML? In filtered mode it will filter out any script tags you put in the body.

----------------------
Drupal by Wombats | Current Drupal project: http://www.ubercart.org

Oh, yeah, Google Adsense

forrestbao - September 30, 2007 - 02:11

Oh, yeah, Google Adsense module works.

I found it didn't work when I wanna create a block only containing Adsense code. I don't wanna use the Adsense module.
Even if I enabled Full HTML, it still doesn't work. I have made it work before. But this time, it fails. I don't know what's wrong. Do you think any else place I need to configure to make Javascript work?

Forrest Sheng Bao
http://forrest.bao.googlepages.com

same problem here

ipwa - September 30, 2007 - 17:28

I am having the exact same problem, I want to have a get firefox referral ad in my site, like the one on http://baheyeldin.com/, which is the site of the adsense module creator. I make a block set it to full html and pasted the script generated by google, then I enabled the block and now more than 12 hours have passed and still nothing. I have tried looking at the site from another computer and it still doesn't work. My site is www.mulpo.com

bump

ipwa - October 2, 2007 - 13:18

Anyone knows why google JavaScript is not working. Some help would be really cool!

only with image ads

ipwa - October 3, 2007 - 01:42

I used the JavaScript for text ads and it works perfectly. But the image ads for any of Google products doesn't work!!! Help please!!!!!

not a problem with Drupal

ipwa - October 3, 2007 - 05:12

I just tested google ads in a html page in server and only text ads display and no image referral ads. I guess Google Adsense setup for image ads is down????????

it is the filters problem

forrestbao - October 18, 2007 - 01:57

I have found the problem. Try to select "Input Format" as "PHP code". Then it may work fine. Might because "Filtered HTML" and "HTML" option filtered some tags.

Forrest Sheng Bao
http://forrest.bao.googlepages.com

yeah it wasn't a problem

ipwa - October 18, 2007 - 02:31

yeah it wasn't a problem with that, the image from Google where down for a few days.

Still can't see Google Adsense ads

Thomasr976 - October 26, 2007 - 18:27

found the Solution

So What is the Google Adsense / Referral Ad Solution?

depp4u - November 2, 2007 - 16:17

So, how did you fix it?
I placed by Google Referral ad code into a block, but nothing shows up - even when I am logged out.

I even changed the input to full html (have yet to try the php suggestion above).

Any suggestions?

Nevermind, It's Working Now

depp4u - November 2, 2007 - 16:23

don't know what I did different, but its working.

images down

ipwa - November 3, 2007 - 02:18

I think that for some reason the images in the server where down. I made a test of a simple html page on my server with the google code for one image and one text ad. At first only the text one would appear, but I checked the same page again after a few days, and it was working.

Nicolas
-------------------------
http://nic.ipwa.net

I guess that it doesn't

Alex8452 - November 7, 2007 - 06:32

I guess that it doesn't appear because you are using the Top administrator account, when you use other account or view pages anonimously, it works fine. see my page: http://www.imalex.net

re: google adsense javascript doesn't work, no ads displayed

kkobus - November 30, 2007 - 05:07

I find that when I take the Google adsense code, I create a block for it, making sure to set the input type to PHP then I need to disable rich text (if you have that option) then paste the google code and save, it works fine.

I think it's a filter problem...

nexus7 - January 2, 2008 - 14:58

If I create a new block unit, put the adsense code, and save al Full HTML code, when I have a look at source's code of my page I found this:
<script type='text/javascript'> &lt;!--google_ad_client

Not this code:
<script type='text/javascript'> <!--google_ad_client

The problem is with <! characters that are filtered... I'm using Drupal 6 RC1 and I'm trying to create a Adsense content using Full HTML...

Bye

i am having the same

mzubair - February 19, 2008 - 20:31

i am having the same problem
can anyone help me out?
Thanks

input format into PHP

perien - March 10, 2008 - 19:45

that worked for me
RVOCE

Old and new output

Imago - January 4, 2008 - 07:34

The old Adsense output works fine, while the new one with the fancy encryption for your settings, is not working in a block frame. So I use the old code.

add me to the list too

unuinu - February 19, 2008 - 20:36

add me to the list too simple cut and paste of adsense new code into a block will not work. I am hoping a 6.0 version of a adsense Module comes out soonish.

You can do like this:1)

ravi_9793 - March 13, 2008 - 21:40

You can do like this:
1) login as administrator -> Modules -> Enable php input format.

Now while writing page/ story/ block -> select php as input format.
This will solve your problem.

http://www.techhunt.org

use module for 6.0

perien - March 14, 2008 - 01:02

For me to get google to recognize the site, I had to copy the tracking code manually into the "custom sippets" section in the module without the modifiers. Check the source code on your site (ctrl-U) to check how it has been inserted.

RVOCE

Respectfully, either

jerseyjoe - March 19, 2008 - 16:10

Respectfully, either something is missing in the above advice or I have a strange installation.

When I login as Admin > Administer > Site Building > Modules

(is that the correct path? because I don't have the shorter path that you describe. I have to first go to Site Building).

After I have Modules open, I see no provision for creating a block or to enable PHP.

Further, the Google code I have on my other web site is in pure HTML, not PHP.

What am I missing, please?

Thank you

I use both the Adsense Module and

Thomasr976 - March 19, 2008 - 16:47

code directly from Google for stories that I create.

Your path is fine. Your code from google is javascript and there is no way to set PHP in the Adsense module. The reason why the script isn't showing is because your input setting is probably stripping out the tags of the google code. Try this instead.

Go to the story/page or node that you are trying to create and have inserted the adsense code. Then edit it. Scroll down and you will see input format. Set the input format to PHP and then preview and submit the story/node again. You should then be seeing the adsense ads. PHP doesn't strip the tags out.

There's also another way to do this. Actually I prefer it since PHP setting messes up my pages.You can go to admin>site configuration>input format and then edit the input format that you normally use on pages where Google adsense appears. Lets say it is Full Html. Click on configure and add "<script>" to the tags that are supposed to be ok. It might be the second tab. Once you add the script tag then save the input format and go back to your story.

Edit the story again and go to input format. Change it to Full HTML. Preview and save and u should see the adsense ad because the <script> has not been stripped out.

Hope this helps. Hang in there.

Fix - make HTML input really HTML input (remove filters)

atr0x - April 2, 2008 - 00:40

Look at your JavaScript error console, the issue is happening in most of these cases because Drupal 6 is doing something different in terms of filtering code, even supposed "full HTML" code. Specifically the <! comment tag in the Google JavaScript is replaced with the &lt; entity, as mentioned above - this causes an error, and the rest of the script doesn't parse.

Error: syntax error
Source File: http://www.yoursite.com/
Line:
295
Source Code:
&lt;!--

I got this fixed on my system by going to
administer->site configuration->input formats and then clicking on configure for Full HTML and UNCHECKING all the filters. I don't know which filter is the culprit specifically (I suspect it is the "HTML corrector"), but one of them is replacing the greater than/less than tags with the entities. Since I really want *FULL* HTML anyway, if I specifically say full HTML (and I only let admins use it), I don't need the HTML corrector and line break parser, etc.

Change full HTML to really mean full HTML, then make sure the input format for your add blocks is set to full HTML, and it works again (just have to keep in mind you no longer have the convenience of those filters, but generally not a big deal if you are expecting to be dealing with pure HTML anyway, when you specifically select it as such).

Oh, and the set to PHP Input mode hack didn't work for me, had to go to actual left alone HTML.

Full HTML without the filters really worked for me

Thomasr976 - April 4, 2008 - 17:02

Before I did this I was using the Adsense and Adsense Injector mods. The google ads delivered by the Adsense Injector mod worked fine. However, when I entered referral ad codes directly from Adsense into my content, they never displayed correctly. After eliminating the html filters, everything worked fine.

Thanks for your help.

This worked!

MorganParker - May 31, 2008 - 01:54

Thank you!!! I didn't think I'd be able to get adsense going until the update of the adsense module, but this has fixed it and it all seems to be working. Can't thank you enough.

Morgan.

Yes this works

mobkarma - April 26, 2008 - 09:36

Thaks, this works. This is the simplest solution for embedding the code. Once you do this wait for some time and the display will work. Just to be sure - do check that input type 'php filter' is only available to the administrator and when saving this block, choose the right input format

Mobkarma - Software, Hardware & Web Tutorials Blog

Thanks, that worked for me.

swinkle - June 29, 2008 - 08:39

Thanks, that worked for me.

I think might be html filter

nut - April 4, 2008 - 04:21

I think might be html filter bug on drupal 6.x, I've used php code block (worked).

Simple Fix without enabling PHP

ZrO-1 - April 19, 2008 - 19:25

So the issue in Drupal 6.2 and Google ads in blocks is the "Full HTML" input format. "Full HTML" input still has the HTML filter enabled. The HTML filter strips/disables javascript.

All you have to do is make a new input format (I called it Raw HTML) and don't turn on any filters. I also only allow the admin to use this input format.

That's it. You don't need to enable the PHP input format at all. Be sure to go back to your blocks or page bodies and change the input format to the "Raw HTML" format to enable the javascript.

working just fine.

webwork1122 - April 29, 2008 - 21:21

Thanks, it's working just fine.

http://www.simplywonderfulworld.com/

Log in as administrator -->>

ravi_9793 - April 19, 2008 - 19:30

Log in as administrator -->> Go to admin panel -->> modules -->> Enable php.

Now while adding content to blocks or to any page/story.....just select php as input format type.

http://www.techhunt.org

Same Issue

houstonp - April 23, 2008 - 21:50

I'm having the same issue. One thing that I've noticed is that the google code doesn't work if you compress it to one line

for example, it works like

[ < script type="text/javascript">

but not with the same code that's like

< script type="text/javascript">

does anyone know how to disable the automatic cleaning / filter when submitting content so it won't automatically compress the lines together?

No module needed to get this

resveld - May 20, 2008 - 16:01

No module needed to get this to work.
Just add a new input format, don't mark any checkbox and apply it.

Make it a normal html file and it will be fine.

what about put it on the block

rejavu - May 21, 2008 - 18:26

what about put it on the block? i'd try to add new type format but it's still displayin nothin..
it happen in php format type too.

You have to add adsense code

ravi_9793 - May 31, 2008 - 02:26

You have to add adsense code in the block. Make title of the block
Select input format as "php". Now enable the block, and wait for 15 mins..because adsense code take around 15 min. to appear.

Free Drupal Themes || Free Wallpapers

Its very simple in drupal 6

_raghu - June 2, 2008 - 18:49

from admin/module/ enable php module

While composing the page or story...
Enable input option: php code
and in between a page or story, add this:

<?php
echo '
.... your adsense code here...
'
;


?>

start writing some more stuff here...if u want....

Hope this helps!

Drupal 6x and Adsense - For the win!

abelleba - June 29, 2008 - 10:47

The above person is right. I figured this out too. I wrote down step by step instructions for all to look at here: http://computerquestionhelp.com/blogs/Misc/getting-google-adsense-to-eas...

Good luck on Drupal 6x

:)

Easy Fix -- here's how I did It

Howard Owens - July 20, 2008 - 22:03

Every time I looked at the source code, I was finding that the start comment was changed to "&lt ; !--"

I had full HTML filter as the input type.

I went to site configuration and created a new input type called Google Ad Sense (name doesn't matter, but I wanted to remember what I was using it for). I didn't check any user role for permissions (don't want this showing but to anybody but me when I'm logged into the primary admin account). Then I DID NOT select any of the other input types in my configuration.

In other words, it's a completely black input type.

Simple solution worked for me

laurentmikhail - September 17, 2008 - 05:33

Hello,

I was also having the same problem:

"Every time I looked at the source code, I was finding that the start comment was changed to "&lt ; !--"

I used HTML and FULL HTML as input format. I just rearranged the filter ordering from the Full HTML input format to this

URL filter
Line break converter
HTML corrector
AdSense tag

I think the HTML corrector filter was changing "<" for "&lt" therefore putting adsese tag after it solved the problem.

It Worked for me, I don't know if it will work for everyone, but try it before changing to php or trying any other more complicated solutions.

Cheers!

 
 

Drupal is a registered trademark of Dries Buytaert.