Getting Adsense to work on Drpal 6

Slugger - January 23, 2008 - 06:56

I've got the site up and running and i tried putting the adsense code into a block with full html access but nothing happens. Apparently the adsense module is not compatible so I was wondering how to get it up and then what would I toggle to share the profits with members?

Consider me a newbie to drupal

Getting Adsense to work on Drpal 6

palvishal - February 20, 2008 - 08:01

The Same Issue I am also facing with Drupal 6. Is it we hold on untill the adsense module update releases for drupal 6 or we move to an older version of drupal.
Is there any othere way to put adsense in drupal 6 ?

Please suggest

I am facing same problem as well,

koyauni - February 24, 2008 - 11:55

I think with all functionality and feasibility around Drupal 6, it fails to address costume module building. It would be nice to be able to create costume module to run small script like Google Adsense.

Custom block.

lenkkivihko - February 24, 2008 - 18:15

I do not know the purpose of adsense module, as you can cut and paste the Adsense code to your custom block.

For more examples, please see: http://drupal.org/node/21867

Harjoituspäiväkirja - www.lenkkivihko.fi

I did but it does not work :(

koyauni - February 25, 2008 - 23:16

I created costume block and pasted my Adsense code, but it does not work, Any idea why?

HTML

Quint - February 26, 2008 - 00:09

did you set it to HTML?

Create A New Input Format

doubleedgedpen - July 20, 2008 - 11:54

1. Go to Administer > Input Formats
2. Add a new input format (I called mine Google Adsense)
3. Enable the input format for any Roles that will need to use it
4. DO NOT select any filters
5. Click Save Configuration

6. Go to Administer > Blocks
7. Add a new block
8. Paste the code from Google Adsense directly into the Block Body text area.
9. Choose the input format that you created above
10. Save Block
11. Configure the block to display where you want it

The "Full HTML" input format does not work for Google Adsense code.
It is not necessary to enable the PHP Filter for Google Adsense Code.
This method is working on my Drupal 6.3 site without the Adsense Module.

Nathan

Yes!

purplekitty - August 11, 2008 - 01:12

Thank you, Nathan! I've been trying to figure this out for hours today. The new input format instructions worked like a charm. In fact, it also has enabled my pop unders code too!

Debi

This works!

andygimpaya - August 20, 2008 - 04:40

This works for me. Thank you Nathan.

Nathan You ROCK!!!

oscardb2 - November 20, 2008 - 22:56

Thanks Man, as a newbie I spent two days trying to figure this out!!! Worked like a charm

Good! Thanks!

Amir Simantov - March 30, 2009 - 17:55

Good! Thanks!

adssense with module

michaeldutton - April 3, 2009 - 20:38

doubleedgedpen's instruction worked great on my website www.rateAprofessional.com

Not working here, with

LM23 - February 26, 2008 - 00:14

Not working here, with pasting adsense code to a new block :(
Ideas?

Thank you very much!

Please can someone

LM23 - February 26, 2008 - 11:09

Confirm if this is not working?
Is there a working way to have adsense as block/module in drupal 6?

Does anyone has a drupal 6 website with adsense?

thanx

Does anyone has a drupal 6 website with adsense?

MidGe48 - November 20, 2008 - 23:41

My web sites do have the AS :)

koyauni - November 21, 2008 - 16:39

www.koyauniversity.org
www.kurdistanica.com
www.kurdishacademy.org

"We must become the change we want to see" [quote: Mahatma Gandhi]

It almost worked

koyauni - February 27, 2008 - 10:42

I did create the block, you have to select Full HTML input format. I do not get any adds thou. I think it cause by me testing sever, I am working without domain where direct IP address appear in the as URL. I am not sure if Google Adsense stop working because of this.

The Class for the Block look strange as it make the 160x600 Google Adsense block to appear as 400x600 which is wider than actual column and mess up the Garland Theme. If some one try to do this customize block with a domain name it would be nice.

I to have this problem. It's

The_cobra666 - February 28, 2008 - 21:09

I to have this problem. It's not working. And yes full html has been set, it doesn't WORK!

It's a problem with drupal 6. No one got a work around?

With FULL HTML and nic edit

LM23 - February 29, 2008 - 00:49

With FULL HTML and nic edit i cant even edit teh block anymore - it loops and loads teh page :(
When i try to edit teh template directly, it want work either ...
omg has no 1 a clue?

Please

If I put the code in the

The_cobra666 - February 29, 2008 - 08:58

If I put the code in the block, drupal even "flips". It doesn't display the options of the block correctly. I've got to refresh the page to make it work correctly... and then it doens't even work like I should work... If I place for example in the page option box "image/*" that it my only display the block on those pages... it saves this to in the body for the block...

There's something wrong with it, without a doubt!

Its work with PHP Code and adsense module.

palvishal - February 29, 2008 - 07:28

After trying out multiple options like making Blocks, by selecting HTML, Filter HTML etc. Finally I make adsense to display some how in my website. I make my new Content by selecting a PHP Code. I have uploaded a PHP Code and Adsense Module to make this work.
If there is some better way to do this please let me know here.

Hi, What PHP and Adsense

The_cobra666 - February 29, 2008 - 08:59

Hi,

What PHP and Adsense module? Does it exist for Drupal 6?

Are you sure you run the

LM23 - February 29, 2008 - 09:13

Are you sure you run the version 6?

Sorry I didn't make it clear last time

palvishal - March 1, 2008 - 07:12

To make adsense work on Drupal 6 I have enabled a module PHP Filter.

Administrator >> Site building >> Module >> PHP Filter

Then after any new content I make, I use the Input format PHP Code Instead of Filtered HTML or Full HTML. You can set it to always open New content by default as PHP Code Input format. To do this go to

Administrator >> Site configuration >> Input formats

Tick on PHP Code and click on SET DEFAULT FORMATS

Second steps is to paste your adsense code. To do this edit the Content page/story as HTML ( I am using a nicedit WYSIWYG Editor, which gives option to edit page as HTML) paste your content between your pages where you want.
I have created a test page to show you all that it works. Here is the link
http://pingoit.com/PingoIT_Testpage_for_adsense

For time being I am Ok with this but I am still searching more advanced method to do this. I will update all about my finding also if anyone else have find any solution for this please let me know.

Why not a Block and PHP filter setting

koyauni - March 1, 2008 - 19:47

why did not you create a block and past the code with PHP Filtering?
It make it is easer to display the block on every page rather than on contact page.

Well to add to this note I just did that myself and it is working
http://98.131.16.97/

What you do
1. activate your PHP filter module
2. Create a block and past your Google Adsense as HTML source
3. Select PHP filter out formate
4. Activate you newly created block

and it works
look at here http://98.131.16.97/ and don't be shy juts click on the adds :)

Block and PHP filter

palvishal - March 3, 2008 - 10:39

I have 2 Column website so don't want Adsense in a block fashion. For me adsense coming between paragraph gives me more output :) as campare to block on lefthand or right sidehand of cloumn.

http://www.pingoit.com

Cheers!

Thank you koyauni and

LM23 - March 10, 2008 - 23:36

Thank you koyauni and palvishal so much !!!!!!!

Web-Design & Music
http://galaxymachine.de

Mine still isnt working any

southfloridafusion - March 26, 2008 - 23:28

Mine still isnt working any ideas?

I did your steps 1-4 and pasted my adsense itno the block as an html source. But, one of two things happens

1. it just shows pasted code
2. it just shows blank box

Here is my link, notice both ads just show code only http://www.steakandeggsdiet.com/

thanks.

datu rocc - July 8, 2008 - 05:43

this worked a great deal.

Thanks a lot........ It

ravi_9793 - March 10, 2008 - 22:45

Thanks a lot........
It worked for me. Actually the previous version of Drupal. 5.X was having php format already in Input Format Type. So, I was little confused about this..Didn't care to see the module.

Thanks :)
my tech Site

thanks

videodoll - March 12, 2008 - 04:05

You just helped me out a lot!

do not chose Filtered HTML or Full HTML

huang_cn - March 11, 2008 - 06:38

simply chose PHP code in input format then you are good to go.

http://voiceofchinese.com/huang

Without PHP Code

charlieman - March 14, 2008 - 06:58

Hi, just to add a comment, I made it work creating a new input format without selecting any of the filters.

Section Targeting

mustardman - March 18, 2008 - 18:02

One problem with creating Adsense blocks or inserting the ad directly into the site is that you do not get section targeting. So adsense may post ads about coding and PHP or whatever it sees in Drupal whereas the content people see may have nothing to do with that.

If you have a purely php theme you can add this into the theme php file

<!-- google_ad_section_start -->
"print page function or body content"
<!-- google_ad_section_end -->

There may be a way to add this into stylesheets if the theme uses that but I don't know how. The adsense module has section targeting built in and I believe optimizes it even better so that would be one advantage to using the module as opposed to creating blocks. I don't have that option as I use Drupal 6.

blocks n sections

DocMartin - July 10, 2008 - 02:44

Or (as I put in later post): I've put ad_section code in blocks, used php filter; one of them above content, the other below. Looking at source code for pages, seems ok.
____________________________
DocMartin and Hong Kong OutdoorsCheungChauHK 長洲HK

Agreed, without PHP

smallzi - April 17, 2008 - 03:00

it works.

block and php filter code

smallzi - April 5, 2008 - 17:35

I created a new block called "ad" that is displayed in the right sidebar, and enabled the php filter module. Below is just the code snippet generated by google, with quotes replaced by apostrohpes, stored as a string, and outputted via echo. It works on http://www.potentialhuman.org with drupal 6.1.

<?php
>
$foo="<script type='text/javascript'><!--
google_ad_client = 'pub-5384434376842053';
/* 160x600, created 4/5/08 */
google_ad_slot = '3339531126';
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type='text/javascript'
src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script>"
;
echo
$foo;
?>

smallzi, Your suggestion

marius.s - April 7, 2008 - 23:10

smallzi,

Your suggestion works, I just had to change:

<?php
>
$foo=

to

<?php
$foo=

ie removed ">" symbol from second line

Marius
www.cringel.com

My bad (typo)

smallzi - April 12, 2008 - 02:50

good catch, marius. here is the code without the mistake

<?php
$foo
="<script type='text/javascript'><!--
google_ad_client = 'pub-5384434376842053';
/* 160x600, created 4/5/08 */
google_ad_slot = '3339531126';
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type='text/javascript'
src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script>"
;
echo
$foo;
?>

Doing so without php is much better

smallzi - April 17, 2008 - 03:04

Looks like charlieman beat me to the punch, but here are detailed instructions:

login as user 1 (the administrator) and navigate to administer >> site configuration >> input formats. Add an input format, and name it whatever unique name you want. Drupal graciously allows for the assignment of roles for input formats. You can keep your users from displaying porn ads in your forums, and still retain the ability to post active content.

Now, the offending filter preventing adsense ads from displaying is the "HTML filter." Enabling or disabling any combination of filters will allow adsense ads to properly display AS LONG AS "HTML filter" is turned off. The HTML filter carries this description:

"Allows you to restrict whether users can post HTML and which tags to filter out. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed."

Adsense ads are displayed via javascript. Go figure.

Translation: configure your format any way you want, just disable HTML filter, and assign roles carefully.

With this new input format enabled, you can post a google generated snippet anywhere and it should display properly.

I'm up and running fine.I

PerryM - July 19, 2008 - 13:26

I'm up and running fine.

I left off the php <?Php and ?> and just used the AdSense code and it works just fine.

Change Input Format to php code

Hawkeyi - April 17, 2008 - 05:44

You have to set the input format to php code. Full HTML is only for html and doesn't allow javascript.

Blocks work when before content

DocMartin - June 17, 2008 - 16:27

Thanks for the info
Just tried block w Google code pasted in, input format set to php (after enabled php module)

Found this worked; but block blank when placed after text - works above it. Might just be glitch w google; but I figure maybe something to do w html filter kicking in with content.
____________________________
CheungChauHK 長洲HK - South China Sea island in Hong Kong.
Hong Kong Outdoors

I do not understand why you have problem

koyauni - June 26, 2008 - 11:11

I have done this for all my projects, just create a block and past the code with PHP Filtering.

It is easer to display the block on every page
please view here
http://kurdistanica.com/

I did this by
1. activate your PHP filter module
2. Create a block and paste your Google Adsense as HTML source (you have to make sure you are not in rich text mode)
3. Select PHP filter formate from the list. This has be e done
4. Activate you newly created block in block section and put it where you wish

and it works

look at here another example http://www.kurdishacademy.org/

blocks for adsense section targeting

DocMartin - June 28, 2008 - 04:37

Just trying using blocks for section targeting

Tried w html, but didn't look good in page source code; the php code trick seems to work here tho.

One block for google_ad_section_start code (which filter deletes here if put in full)

another for google_ad_section_end

in theme settings (Zen, lest yours lacks these places), placing these at top and bottom of content. Looks ok in page source.
____________________________
CheungChauHK 長洲HK - South China Sea island in Hong Kong.

Finally found a simple way

abelleba - June 29, 2008 - 10:02

Finally found a simple way of getting google adsense to work on Drupal 6 using a block. These instructions actually work and are well detailed using a default theme.
http://computerquestionhelp.com/blogs/Misc/getting-google-adsense-to-eas...

Simple Ad Block

koyauni - July 30, 2008 - 12:26

This is a module for D6x

http://drupal.org/project/simplead_block

"We must become the change we want to see" [quote: Mahatma Gandhi]

The Solution

Team Covenant - August 4, 2008 - 22:12

The solution was posted by nathan, above:

1. Go to Administer > Input Formats
2. Add a new input format (I called mine Google Adsense)
3. Enable the input format for any Roles that will need to use it
4. DO NOT select any filters
5. Click Save Configuration

6. Go to Administer > Blocks
7. Add a new block
8. Paste the code from Google Adsense directly into the Block Body text area.
9. Choose the input format that you created above
10. Save Block
11. Configure the block to display where you want it

All you have to do is create an input format without any filters whatsoever. Then, make your block that setting and you will be good to go. Here is the site I did this with:

http://community.teamcovenant.com

Good luck...

Zach

Thanks for the clear and

magicflea - August 19, 2008 - 12:33

Thanks for the clear and easy to follow instructions. And most importantly, it seems to work properly to feed appropriate Google ads based on your site content.
stephen

remv

neocary - August 20, 2008 - 08:22

remv

Great Job-Thank you very much

neocary - August 20, 2008 - 08:30

Thank you very much

No need to use the PHP input format

Ahqar - November 9, 2008 - 21:04

Why enable the PHP input format if it's not needed?

Also creating a custom input type for each type of script is unnecessary.

Just create a single input type with all filter settings turned off and call this input format "UNFILTERED".

Here's how:
_____________

Go to the following url

yourdomain/admin/settings/filters

or click the links from the admin section to take you there:

Home > Administer > Site Configuration > Input Formats

Now create a new input type and DESELECT all of the filters for it.

i.e.the following should all be unchecked:

HTML corrector
HTML filter
Line break converter
URL filter

Check the relevant boxes to assign the user that is allowed to use the new "Unfiltered" Input Format and you are done.

Now just select this input format every time you want to paste in third party scripts into blocks or content.

It works with adsense code, Amazon code etc.

Good luck

(By the way I think this input type should be included as standard in all new installations)

Also works well with the 6.x-1.x DEV adsense module

jsmart377 - November 9, 2008 - 23:44

Ahqar,

Thanks for a lifesaver!! I really wanted precise control within my content of where the ads would appear and needed section targeting to work due to the nature of the site requirements.

Was going to great lengthes trying to get the DEV 6.x Adsense Module (11/08/08 rel.)working since global management is much easier. Could not get ads to display until I did as instructed above:

Removed: from "FULL HTML" configuration

HTML corrector
HTML filter
Line break converter

from Home>Administer > Site Configuration > Input Formats

For the "Leaderboard" to display centered just below my content I inserted:

[adsense:728x90:xxxxxxxxx]

(where xxxx is the "slot ID" from Google Adsense site, and also configured in my Managed ad block)

I also have a Managed Ad block configured for this ad type but not enabled for any region (check advanced help with module)

This latest version also has a "click tracking" feature which I am sure will offer more inteligence on where your click traffic originates!

Hope this helps others who may be struggeling with the Adsense Module & Drupal 6.x !

JS

It Worked!

DraeZ - September 27, 2009 - 06:06

Creating an unfiltered input format did the trick.

Thanks!

I only need to decide if the ad should match my sign design, or if it should purposely look different.
http://www.takenpath.com

 
 

Drupal is a registered trademark of Dries Buytaert.