When people land on your page from a search engine it may help to optimize Ads based on their search keywords.
For example, I believe that Ad$ense responds to the nearby keywords on a page. So you can insert the keywords dynamically near to the Ad unit. Ordinarilly you don't need to do this, but if your page is a bit general in nature, it may help.
Here is some code that I dug out from one of my sites:
This code is a bit old now, but hopefully it still works. Basically it gives you a keyword string to use to formulate a paragraph of text above the Ad.
Better still may be to store the previous say 10 search terms and display them in a list e.g. visitors recently landing on this page were looking for ...
Then the keyword update is smoothed over more.
Maybe you guys have some other ways to achieve this to share in this thread?
For example, I believe that Ad$ense responds to the nearby keywords on a page. So you can insert the keywords dynamically near to the Ad unit. Ordinarilly you don't need to do this, but if your page is a bit general in nature, it may help.
Here is some code that I dug out from one of my sites:
PHP:
$subject = getenv("HTTP_REFERER");
if (strpos($subject, 'search') > 0){
$pattern = '/q=([^&]+)/';
preg_match($pattern, $subject, $matches);
if ($matches){
$r = $matches[1];
} else {
$pattern = '/p=([^&]+)&/';
preg_match($pattern, $subject, $matches);
if ($matches){
$r = $matches[1];
} else {
$pattern = '/query=([^&]+)&/';
preg_match($pattern, $subject, $matches);
if ($matches){
$r = $matches[1];
} else {
$r = '';
}
}
}
$keyword = str_replace('+',' ',$r);
$keyword = str_replace('%20',' ',$keyword);
$kw = strtolower(str_replace(' ','-',trim($keyword)));
$keyword = ucwords($keyword);
This code is a bit old now, but hopefully it still works. Basically it gives you a keyword string to use to formulate a paragraph of text above the Ad.
Better still may be to store the previous say 10 search terms and display them in a list e.g. visitors recently landing on this page were looking for ...
Then the keyword update is smoothed over more.
Maybe you guys have some other ways to achieve this to share in this thread?