Forum Moderators: martinibuster

Message Too Old, No Replies

External JavaScript file, NO says Google

AdSense cannot be put in an external JavaScript file, says Google.

         

shafaki

11:38 pm on Feb 10, 2005 (gmt 0)

10+ Year Member



Below was Google's response to my inquiery about putting AdSense in external .js (JavaScript) files:

<paraphrase by moderator>
AdSense ad code cannot be placed in an external .js file as this would require the AdSense code be altered, which is against the AdSense terms and conditions
<paraphrase>

[edited by: Jenstar at 2:52 am (utc) on Feb. 11, 2005]
[edit reason] No email quotes as per TOS, thanks! [/edit]

idonen

1:29 am on Feb 11, 2005 (gmt 0)

10+ Year Member



Why would you want to put them in a javascript file, so you can avoid having the big block of extra code cluttering up your pages?

You could always do it with a server side include, or depending what web server you're using, some other sort of server-based code. That way you wouldn't be altering google's code at all.

dollarshort

1:38 am on Feb 11, 2005 (gmt 0)

10+ Year Member



Putting the javascript code in a .js file does not modify it in any way, its like a wrapper function, I do not see any problem doing it unless they specifically say not to.

level80

2:44 am on Feb 11, 2005 (gmt 0)

10+ Year Member



It doesn't modify it, but:-

The Adsense program looks at the file it's been called from - if it's being called from:-

googleadsense.js

rather than

index.htm

it'll show generic site targeted ads rather than context sensitive ads (which is the whole point of Adsense anyway).

Oh and it slows down the ads showing, as the browser has to request the javascript file, read it, call the Google javascript etc.

[edited by: level80 at 2:50 am (utc) on Feb. 11, 2005]

PatrickDeese

2:49 am on Feb 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Much better to use SSI - I have all my adsense inserted with PHP includes - so I can test new colors etc.

In fact, I am using PHP includes with all my aff stuff much easier to swap out aff programs, add seasonal promotions etc.

daugava

8:32 pm on Feb 11, 2005 (gmt 0)

10+ Year Member



Placing Google code in external JS file would require modification, since the code contains a "<script" tag, which is an HTML tag, not a Javascript statement.

Doing it with SSI includes is a supported alternative, although it's quite a bit more hassle, since SSI doesn't support absolute paths - so, for every page you'll have to use the correct relative path to the adsense include file.