Welcome to WebmasterWorld Guest from

Forum Moderators: martinibuster

Message Too Old, No Replies

AdSense in external .js file

Are we allowed.....

12:07 am on Aug 17, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 23, 2003
votes: 0

I have read their TOS and have not read anywhere that says it cannot be done without violating the TOS. I searched high and low for answers with nothing. Are we allowed?
12:19 am on Aug 17, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 4, 2003
votes: 0

The problem with including the AdSense code via an external .js is file is that the ad code will most likely require modification, which as you correctly noted is against our Terms and Conditions. Also, the ad code needs to be displayed in the HTML source of the page in order for our crawlers to index your content properly.

One option for you is to include the ad code via a server-side include (SSI). If done correctly, the ad code will show up in the HTML source of your pages as if it had been directly implemented.

Hope that helps!

1:50 am on Aug 17, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Aug 3, 2004
votes: 0

Well, I've been using Adsense code from external .js files for quite a while. Though the javascript itself may not be "unmodified AdSense code", it inserts unmodified code into the page.

While AdSense have contacted me about a couple of other issues on the site (which I took care of right away to their satisfaction), I've never had a complaint about my serving the AdSense code via external .js files, so I'd assumed it wasn't a problem for them.

I've had no problems at all with the ads not being targeted to my content. On most pages the targeting is very accurate.

Unfortunately the host I'm with doesn't offer SSI, so .js files were the only way I could put the code on all my pages without hardcoding it into every page. That's fine, but makes making changes a bit of a pain!

If I'm violating AdSense TOS, I'd like to know for sure so I can try to keep within the rules!

2:46 am on Aug 17, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Aug 3, 2004
votes: 0

But what actually constitutes "modification of the AdSense code"?

The code I'm serving IS the AsSense code. All the .js script does is serve it up line by line. The code supplied to your browser is EXACTLY the same code that AdSense provides from their web page. Your browser can't tell the difference, though of course the HTML source code for the page doesn't contain the AsSense code, it contains a call to the .js file containing the AdSense code.

I would maintain that I'm not modifying the AdSense code, I'm just not serving it directly from an html file. The TOS don't say you have to serve it directly from an HTML file as far as I'm aware.

If course if the OFFICIAL Google position is that this is totally prohibited and if they find me doing it I'll be booted off the program, then I'll get to work making modifications, but as I said, I've been running it that way for the best part of a year, Google have looked at my site and pointed out one area where I wasn't quite in compliance with their TOS (which I corrected), but they never commented on the use of .js files containg the AdSense code. I don't have it on ALL my pages, but I'd guess maybe 1/2 of them.

Perhaps I need to send (anonymous) email to them to ask for an offical ruling. I'd rather do it anonymously just in case they hadn't noticed it and get upset about it!

As I said, I seem to be getting perfectly targeted ads which are closely related to the content of each page. If there's some technical reason why Google need the AsSense code in "plain language" in the HTML source, then I hope someone can explain that to me. Of course Google don't have to since "rules is rules", and I accept that. I'd just like to know since it's going to be quite a bit of work for me to modify several hundred pages!

4:43 am on Aug 17, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Aug 3, 2004
votes: 0

Well, it's Javascript, not Java, and clearly copying and pasting it is OK (what else would you be expected to do with it!).

I'm just wondering if Google does indeed need to see the actual Javascript on the HTML page. If it's served from a .js file, the same data goes to Google as it would if it were copied verbatim into the HTML source.

The only difference would be when Google crawled the page, but does the regular Google crawl have anything to do with Adsense? If Google is using it's regular crawl data to decide which ads to serve for a particular page, I'm not sure why it would need to see the explict Javascript source on the page.

When the call is made to Adsense to download the ads, I presume it knows which page it's coming from and the call transfers exactly the same data as it would if the Javascript was placed directly on the page. If Google has crawled the page, it knows what's there in terms of content and so it knows which ads to serve. None of the data sent by the AdSense Javascript identifies the page it's included on. It just sends account ID and Ad formating information whether it's loaded from a .js file or sits directly on the page. The page ID is sent in the headers I assume and isn't related to the actual Javacript data.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members