Google AdSense ads: Now on TBOTCOTW
Don’t bother refreshing if you don’t see them, they aren’t there… unless you got here via Google. Or, more accurately, unless you got here via Google, Yahoo, or a couple other search engines. Brad Choate gave me the idea, although at this point he’s gone and changed his blog to show ads to every visitor. I might do the same in the future.
What I was actually looking for on Brad’s site was how he prints the ad after the first post on every page, but not after every post. I still haven’t figured that out, so for now I’ve got a banner at the very top of the page and a button in the sidebar (If you want to see what the ads looks like search for “matt moore” in google and hit the “I’m Feeling Lucky” button). Instead I found his brilliant idea to show Google ads only to Google visitors so I don’t penalize my regular readers by trying to make a buck. He used mt-refsearch to display the ads, but that seemed like overkill to me (and that plugin probably isn’t compatible with dynamic pages, anyway). So I wrote a little bit of PHP to do the same thing on a smaller scale.
<?php
$referer = $_SERVER['HTTP_REFERER'];
if ( ereg ( "google.com", $referer ) || ereg ( "altavista.com", $referer )
|| ereg ( "lycos.com", $referer ) || ereg ( "yahoo.com", $referer ) ) {
echo <<<END
<script type="text/javascript"><!--
google_ad_client = "pub-###";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "A3B8CC";
google_color_bg = "DAE0E6";
google_color_link = "36419D";
google_color_url = "36419D";
google_color_text = "000333";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
END;
}
?>
Of course, fill in your own AdSense code between the END statements. Wherever I stick this script the ad is shown only if the user was referred here by a handful of search engines. Pretty neat, and so far I’ve made 68 cents. Only $99.32 until they cut me a check!
Popularity: 2% [?]
I didn’t find the script mt-refsearch. Can you post me the script?
BTW, I like to know, how you count the pageviews of the entry?
Thank you for your help.
Like I said, I don’t use mt-refsearch, so I don’t know where it is.
For pageviews, look here.
Thanks for your help an the tip!
)