View Full Version : Where to find this script showing ads only via search visitors?
socialpreneur
01-11-2008, 04:26 AM
I've seen people commenting here that they use some kind of script for advertisements to be only seen by visitors via search engines. But I can't find the right word to Google.
Can you share us where you get that script from?
Jeremy
01-11-2008, 03:25 PM
Mine is just hand-coded, I'm not familiar with any sort of standard script. Wordpress does have a plugin of some sort that does something like this, but I like to have full control. Here is what I use, and I put it at the beginning of a post in the main index template so that it is injected right in the content.
<?php if (substr(getenv('HTTP_REFERER'), 0, 22) == "http://www.google.com/") {
echo "<div style=\"float:left; margin-top:1em; margin-left:1em; margin-bottom: 0.5em;\">";
echo "
<script type=\"text/javascript\"><!--
google_ad_client = \"pub-xxxxxxxxxxxxxx\";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = \"300x250_as\";
google_ad_type = \"text\";
//2007-07-01: Google Referrer Inside Content
google_ad_channel = \"5003101554\";
google_color_border = \"FFFFFF\";
google_color_bg = \"FFFFFF\";
google_color_link = \"A83000\";
google_color_text = \"000000\";
google_color_url = \"E6E6E6\";
//--></script>
<script type=\"text/javascript\"
src=\" http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>";
echo "</div>";
}
?>
Make sure you keep all the slashes and quotes in there or it won't work.
To see how it works, if you click on my link at the top of these search results: how to become a millionaire - Google Search (http://www.google.com/search?q=how+to+become+a+millionaire)
you'll be taken to my page with the ad inserted. That inserted ad is by far my highest earning ad unit. eCPM is about 10 times that of the other ads.
socialpreneur
01-12-2008, 03:02 AM
You mentioned there's a plugin for this, do you remember the name?
Is it possible to add another URL? Google (http://www.google.co.jp) , etc?
Jeremy
01-14-2008, 03:31 PM
I'm sure you could add other search url's, yes. I'm guessing somewhere in that first line of code you could include some kind of OR statement, but I have no idea how to do that since I suck at php. I just tweaked this code from a friend.
And sorry, I don't recall the name of the plugin.
socialpreneur
01-18-2008, 01:04 PM
I found this code wonderfully working.
<?
if (preg_match('/^http:\/\/(\w+\.)?(google|msn|yahoo|aol)\./',$_SERVER['HTTP_REFERER']) == 1)
{
?>
<!-- Google AdSense HTML -->
<?
}
?>
selective google adsense and firefox ads - malevolent design weblog (http://www.malevolent.com/weblog/archive/2006/02/07/google-adsense-firefox/)
ses5909
01-25-2008, 01:05 PM
Thanks for updating the post with your code as well.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.