Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL & martinibuster

Message Too Old, No Replies

Adsense in external .js file?

Simple question, is that allowed



5:43 pm on May 1, 2004 (gmt 0)

10+ Year Member

Please excuse this rookie question.

Is it OK to put the Adsense javascript code in an external javascript file, or must the code appear directly within the html file that uses it.


8:23 pm on May 1, 2004 (gmt 0)

10+ Year Member

I have one javascript file that apply adsense code to all site pages, and impressions and click are regularly registered.


6:03 am on May 2, 2004 (gmt 0)

10+ Year Member

No it is not allowed. I have asked them.


8:25 am on May 2, 2004 (gmt 0)

10+ Year Member

There's another thread about Adsense in an external javascript:


Reply from the Google Adsense team: "code cannot be altered in any way"...


7:16 pm on May 2, 2004 (gmt 0)

10+ Year Member

Can we use SSIs or PHP to serve different ads from the same pages? I mean, does Google care if a given page serves different ads each time it's visited? The ads would change, but all would come from a stock "written" by Google, with no changes inside the scripts.

Possible uses: (1) serve different colors or sizes to reduce ad-blindness, (2) serve different channels, tracking anything knowable—hour of day, member status, (3) tie differences in aesthetics to channels, to track the most effective colors, sizes, etc.

I asked this question here once before, but got no replies. Google misunderstood my question and sent me a form letter about how to insert JS into webpages.


7:19 pm on May 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I have my adsense code in a SSI file, this does not alter the code in any way and I can change all the ads with the switch of one file.


7:43 pm on May 2, 2004 (gmt 0)

WebmasterWorld Senior Member jomaxx is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Some of those changes will trigger a reindexing of the page by AdSense (specifically ad sizes; not sure about color changes or channel changes).

I don't see why you couldn't swap AdSense in and out using PHP or SSI, but I would be careful about constantly changing the ad format. You might conceivably get some bizarre side effects, such as excessive spidering, poor targeting, or frequent manual checks from Google staff.


6:18 pm on May 6, 2004 (gmt 0)

10+ Year Member

Thanks Tombolo, for posting that link to the previous thread on this topic, and thanks to the others who replied too. The first post in that previous thread, had the most desirable way to do Adsense as an external javascript file. Too bad the official word so far, is that its not allowed. So, wouldn't it be nice if..

Google, most esteemed AdsenseAdvisor,
Could you please add a little code into your algorithm that checks if pages are using un-adulterated Adsense code... to add the option to use a specific external javascript file, which is restricted to containing ONLY the 12 required lines to set the Google_variables values.? Your checking algorithm should be able to figure that out, and it would make format changes to large sites, sooo much easier.


Featured Threads

Hot Threads This Week

Hot Threads This Month