How does google calculates which ad to be placed. -Is it from its record of keywords which google gathered when google bot accessed my page? - Is it from the current content of the page. if so then which part of the page. For example i placed my "ad code" just after body tag. As no content was there just after body tag, what will be happen in this case. Will it just base on header or whole page's content will be loaded and then google will display its ads.
Google bot analyzes the page that your adsense ad is on based on its content. If your content changes frequently and the bot doesn't crawl that page frequently, you can get "stuck" with whatever it has determined to be relevant. For example, a front page that has many different types of categories (sports, environment, programming, stocks) will get a variety of ads filled on the ad unit. Also note that you are working with two issues here - ad relevancy and position. For position, its best to experiment with different ad locations on the page. However, if you want the best CTR, stick to the Google heat map. Sometimes its best to put Adsense on your lower level pages to draw in better relevancy.
I believe that is correct softvision. I believe it tries its best to determine the type of content on the first few page hits. When you first put an ad on the page, there is a delay of a few minutes so that the bot can come into the page to crawl it and analyze its content. However, if say content on that page changes 30 minutes later to something completely different, I dont think you can expect it to match well. I believe it "learns" your website over time. I wouild think it would not be responsive if a user hits a page and then before rendering the ad, adsense have to go and determine what type of content is on that page before it renders it - it would cause a delay. It may do that every "n" hits and keep an internal counter on their end. Perhaps use of Google Sitemaps can help if they tie it in together as you can specify the page frequency of change in your sitemap. Best thing to do is experiment. Lets assume you put a adsense ad on the front page: If your site is about dogs, you are likely going to get dog ads as Google learns more about your site. If your site is about cats, dogs, and parakeets you are likely going to get that and general pet ads. But if you throw in content like dentists, I'd say you wont see many dentists ads on the front page - more likely on deeper pages 2nd and 3rd level down with dentist articles. Hope this makes sense.