Forum Moderators: martinibuster

Message Too Old, No Replies

when modification on the code is needed.

         

dulldull

7:17 pm on Sep 20, 2008 (gmt 0)

10+ Year Member



my website is generated by a dynamic PHP and in order to insert the google adsense code for my website, i have to set a variable for the code.

However, the original code for Adsense doesn't work at all. No ads were shown, and i had to modify it a little bit like this:

<script type="text/javascript">
<!-- <--- remove this line
google_ad_client = "pub-1111111111111";
/* 120x600, 08-9-19 */ <--- remove this line too
google_ad_slot = "11111111111111";
google_ad_width = 120;
google_ad_height = 600;
//--> <---- and also this line
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

After these small modifications, the ads can be shown now, but there's a strange performance. The number of ads shown in Adsense report doesn't quite match my web stat. It seems that the ads were shown, but didn't count into my report.

And according to the terms and conditions, any modification of the code is not allowed. For this concern I've removed this ad now.

Did anyone experience similar problems with PHP before?
And did you modify your code? Is it accepted by Google?

jdMorgan

7:25 pm on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You removed your publisher ID from the ads, so naturally you did not get credit for them.

Rather than modify the Adsense code --which is not allowed-- you should find out *why* your PHP script seems to require that modification. It may be that your script cannot deal with quoted text properly, or something relatively simple like that.

Jim

swa66

8:02 pm on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest to contact adsense-support and get permission on any change you're force to make. I got permission to make a minor change (to get xhtml 1.0 transient compliant code) years ago this way.

Marcia

8:20 pm on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're not allowed to change the Adsense code (at least not without specific written, documentable permission), it's stated very clearly in the TOS. A PHP script can be modified, so that's what's best to be done, it's the easiest solution.

[edited by: Marcia at 8:25 pm (utc) on Sep. 20, 2008]

koan

9:38 pm on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't change the code. You should try to publish the adsense code using PHP without print or echo functions where you need to escape the " ' ", using "includes" or a " <?php if () { ?> INSERT ADSENSE HERE <?php } ?> " type of function.

eeek

10:58 pm on Sep 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just what are you using to set this variable?

dulldull

8:33 am on Sep 21, 2008 (gmt 0)

10+ Year Member



the variable i set is like this:
$adlink = '<script type="text/javascript">';
$adlink .= 'google_ad_client = "pub-#*$!#*$!#*$!#*$!#*$!#*$!x";';
$adlink .= 'google_ad_slot = "#*$!#*$!#*$!x";';
$adlink .= 'google_ad_width = 468;';
$adlink .= 'google_ad_height = 15;';
$adlink .= '</script>';
$adlink .= '<script type="text/javascript" ';
$adlink .= 'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">';
$adlink .= '</script>';

And if i add the comment tag provided by Google Adsense, the ads won't be shown.

The problem is just solved now.

The google support team says the comment tag won't affect ads match, so it's okay for me to remove it. As long as i don't do anything to affect ads matching, it's acceptable.

himalayaswater

9:12 am on Sep 21, 2008 (gmt 0)

10+ Year Member



no need to use $adlink:
use
echo 'code line 1
line 2
line ';

dulldull

6:04 pm on Sep 21, 2008 (gmt 0)

10+ Year Member



I'll change my code to make it easier. Thanks a lot, himalayswater!

eeek

7:43 pm on Sep 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



echo 'code line 1
line 2
line ';

What's wrong with just escaping out of PHP and pasting in the Adsense code?

netmeg

2:31 pm on Sep 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yea, I'm not sure what the issue is. All my sites are in PHP; I've never had a problem, and I have multiple AdSense and affiliate ads for most spots - just serve them up randomly from a PHP include. Never had to modify any code.