Yeah, the Google AdSense text ads and their tiny brethren, the link units, are back to the trenches, here and there on every page of this blog and the main website’s, doing their thing —hopefully— the way I expect them to do it.
I’ve had this account for more than three years and never really figured out a way to put it to work, first because I just couldn’t bring myself to not hating website advertisment and second, because I simply couldn’t find a way to make Google’s shitty code hum in my
application/xhtml+xml web pages…
Stubborn as I am, I ditched from the start the idea of switching back to
text/html just to accomodate the way Goggle decided to write their add units (i.e.
text/html) so, basically, I ended up gathering a 3–year thick layer of dust on my Google AdSense account…
Which seems to have been an awful fucking shame :)
So, stuck between the impossibility to plant ads on my web pages and the stubborness that kept me from modifying my own markup so I can get it done, I spent the last three years looking for a workaround.
Nowhere to be found, nowhere to be found… Until today.
When, with a little spare time on my hands, I decided to give it another try.
And what do you know, a quick Google on “Google Ads application/xhtml+xml” solved it like it never existed! Right on top of the search results, Stu Nicholls’ “Adding AdSense to application/xhtml+xml pages” and Simon Jessey’s “Why won’t AdSense work with true XHTML?” which, between the two of them, explained every single thing I needed to know and shared a handful of snippets to make it even easier.
Shit! how did I manage to not find these two gems, only I and my chaotic googleing habits know :D The solution is very elegant and perfectly “legal”, as far as Google’s terms and conditions go. Not getting into (more XHTML–mumbo-jumbo) details, since the workaround is so simple and the time I wasted before finding it is so long that the whole thing is rather embarrassing, but the only trick needed was calling the ad units through an
object element —with the
type="text/html" specified— from external files served as
text/html… And that was it.
Bottom line, the ads work just fine and, to counter laziness with excess, they’re being displayed on all the pages, here and at the main site. New, shiny, little toys… hopefully, close enough to whatever topic on the respective page, because what’s an ad without a click? :)
A very thankful hat tip towards Stu Nicholls and Simon Jessey, a very satisfied big grin on my face and preparations to become a millionaire under way :)
P.S.: If you’re on Safari, you won’t see them. I couldn’t find a way to make Apple’s *teh* stupid browser display the ads without a bunch of ugly scrollbars around the
object, so I’m only serving them to Firefox (Mozilla and Camino too, naturally) and Opera. The ads are probably visible in Internet Exploder too, but I didn’t bother to check and who cares anyway? NetNewsWire does what Safari does, but no one wants ads in a feed reader, so I guess it’s not a big deal.
Yep, that’s it. Pheew…