How to advertise on a pure AJAX application?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kevin_Cho
Posted On:   Friday, July 14, 2006 03:42 PM

This is my first time posting an IT solution. Hopefully someone will google this and find it helpful. It's really a simple solution but I wished someone posted this and save me 2 days of headache. For a while I had a dillema on how to show ad on a 100% ajax web site. It's totally unfair to show only 1 impression of ads while the user is browsing your site. Currently, I'm using Google's Adsense and they don't give any help on Ajax Web thus I had to come w/ my own solution. Of course there was some help on the web to do this but it was a combination of results + my own solution that made it work. Ok~ so let see what is fair use of this adsense. In my opinion (yours may differ..even Google)   More>>

This is my first time posting an IT solution. Hopefully someone will google
this and find it helpful. It's really a simple solution but I wished someone
posted this and save me 2 days of headache. For a while I had a dillema on how
to show ad on a 100% ajax web site. It's totally unfair to show only 1 impression
of ads while the user is browsing your site. Currently, I'm using Google's Adsense
and they don't give any help on Ajax Web thus I had to come w/ my own solution.
Of course there was some help on the web to do this but it was a combination
of results + my own solution that made it work.


Ok~ so let see what is fair use of this adsense. In my opinion (yours may differ..even
Google), if there's a content change in your web site then it's fair to show
a new ads on your page. Since I'm using AJAX, the best place to refresh the
ad would be where you're making your HTTP request to the server. Example!


var oXmlHttp = createXMLHttp();


oXmlHttp.onreadystatechange = function() {

     if (oXmlHttp.readyState == 4) {

          var storyDiv = document.getElementById(layerName);


          storyDiv.innerHTML =
oXmlHttp.responseText;



           refreshAd();


      }

};



refreshAd() will refreash the ad. No better place then here. Do not put this
under any onClick/onChange/onAnything behavior as it will only complicate your
page like onClick="doSomething();refreshAd();"


// Need to pass unique URI each time to make sure that your browser does not
cache the result! This is needed for Firefox specifically!

function refreshAd() {

      var currentTime = new Date();

      googlead.location = "pages/ad.jsp?s=" + currentTime.getTime();


}



That's right! I'm using IFRAME.. I can already see you're not surprised as if
you already know the solution. There's really no other option since any other
solutions will be breaking Google's TOS.


Great! I got my IFRAME to refresh on every HTTP/AJAX request.. but what the
hell! it only shows Public Service Ad. I want to show ads that's related to
my site!

Now in order for Google to content search your page... the content has to be
inside wherever you put your google adsense script. For now this is what I had.



--ad.jsp--



   <<Less

Re: How to advertise on a pure AJAX application?

Posted By:   Kevin_Cho  
Posted On:   Tuesday, August 8, 2006 01:49 PM

I have a working sample site www.weekendstory.com . Try to click on any links and you'll see that it's refreshing the IFRAME page.

Alot of people said this is against google TOS but here's a proof that it's not in their FAQ. If they answered this question, I'm assuming IFRAME is legal.

Why am I getting PSA's?
The AdSense ad code was placed within an IFRAME.
Our targeting technology is not optimized to serve ads within a separate IFRAME. If you placed the AdSense code in a separate IFRAME, your site may display less targeted ads or public service ads. For better results, please implement our ad code directly into the source of your web page. Once you make these changes, relevant ads may not appear immediately. Until we are able to re-crawl your site, which may take up to 48 hours or more, your page may continue to display untargeted or public service ads.
About | Sitemap | Contact