… at the intersection of News, media, technology, business and the web
1 Apr
After releasing my AjaxBerlee WordPress theme George and Milan’Che
reported problems with Google’s AdSense. This left me with a problem.
Because new page requests in my theme are parsed over the old ones.
AdSense works as follows. The Mediapartners-Google spider indexes the site,
when visitor now requests one of your pages it will load the external
JavaScript from the Google domain. In that JavaScript the text advertise is
displayed.
So far so good. An AJAXified page will initially display the AdSense
advertise very well (because the pages are backwards compatible). The
visitor clicks on a link and now only a part of the page get reloaded, but
not the AdSense advertise. Because it’s possible to load an JavaScript
into JavaScript, but its not possible to reload JavaScript into JavaScript
(for scripts that aren’t build for it).
I suspected that Google had some kind of a refresh function build in where
I could specify which URL the currently displayed AJAXified site was. So
when you click on an AJAXified link, the Ajax JavaScript calls a Google
refresh function. (this is actually how the Google Analytics support works
in the AJAX JavaScript)
I was surprised to find out that there was not such a function in the
AdSense JavaScript. So I tried to find out how AJAXified sites like Google
Maps and GMail works with AdSense. Well, actually, they don’t!
GMail has some uses some AJAX function to display realtime new incoming
messages, but the actually displaying of mail goes thru frames and plain
old loading of pages! And Google Maps actually doesn’t use AdSense at
all… Well, they do, but its parsed into the page and doesn’t use
external JavaScript at all, as described above.
I found one workaround by Kevin Cho who used an iframe. In that iframe the
AdSense got loaded with the keywords of that page specially dedicated for
AdSense for that site. You need to type these manually, which is a hell of
a job if you have a lot of pages. And it’s probably against the Program
Policies which are very clear about cloaking.
I decided not to implement that workaround because of the Program Policies
violation. But I will publish a modified ajax.js that is compatible with
AdSense but does not have the enhanced page loading.
One Response for "AdSense and AJAX: Not a happy combination"
Good one…
Leave a reply
You must be logged in to post a comment.