≡ Menu

PHP Script to Target Ads to Your First Time Visitors

Wow, I thought this is a brilliant idea – “Display Advertising Without Annoying Your Regular Readers” by Dan of TheWrongAdvices.com. It is a simple script.

<?php
$referer = $_SERVER[’HTTP_REFERER’];
$url = strtolower(urldecode($referer));
if ( eregi(”www.google((.[a-z]{2,3}){1,2})[/]search”,$url) )
{ ?>
INSERT YOUR AD CODE HERE
<?php } ?>

Basically, it checks from where is the visitor coming from. If it’s from Google search, then the ad is displayed. For your blog’s regular readers who come to your page via bookmark, direct keyboard entry or any other web pages, no ad will be displayed.

Darn! Why didn’t I thought of it earlier. This will definitely please some of my readers. I am going to test this out now.

P.S. You page has to be a .php in order to use this script otherwise you’ll have to tweak your .htaccess to enable html to behave like .php.

{ 0 comments… add one }

Leave a Comment