How AdSense works
For contextual advertisements, Google's servers use a cache of the page to determine a set of high-value keywords. If keywords have been cached already, advertisements are served for those keywords based on the AdWords bidding system. (More details are described in the AdSense patent.)
For site-targeted advertisements, the advertiser chooses the page(s) on which to display advertisements, and pays based on cost per mille (CPM), or the price advertisers choose to pay for every thousand advertisements displayed.
For referrals, Google adds money to the advertiser's account when visitors either download the referred software or subscribe to the referred service.The referral program was retired in August 2008.
Search advertisements are added to the list of results after the visitor performs a search.