Contextual advertising or targeted advertising is the term applied to advertisements appearing on websites or other media, such as content displayed in mobile phones, where the advertisements are selected and served by automated systems based on the content displayed by the user.
Google AdSense was the first major contextual advertising program. It worked by providing webmasters with JavaScript code that, when inserted into web pages, called up relevant advertisements from the Google inventory of advertisers. The relevance was calculated by a separate Google bot that indexed the content of the page.