Weekend Projects – Search Engine Visitor Greetings
Posted on July 5th, 2009
This week based on some requests of customers we will adding some PHP code to our site to redirect users based on the search engine details.
This first example will allow you to display a greeting message based on the search engine. You could also use this to display ads to specific search engine users. For example Google users are said more likely to click on Google Ads because they recognize them. Where someone that comes from Digg is most likely not to click on Google Ads. Add the following code to welcome Google users…
<?php
$host = $_SERVER['HTTP_REFERER'];
if (strstr($host,”google”))
{
Print(“Welcome google user. Thank you for visiting our site.”);
}
?>
Now you can modify this script to show a custom message based on a keyword…
<?php
$host = $_SERVER['HTTP_REFERER'];
if (strstr($host,”server”))
{
Print(“Looking for a server? Look at our server offerings”);
}
?>
Lastly you could modify the script to output the keyword in your message if the user used Google like this…
<?php
$host = $_SERVER['HTTP_REFERER'];
$s1 = explode(“p=”,$host);
$s2 = explode(“&”,$s1[1]);
$keyword = str_replace(“+”,” “,$s2[0]);
if (strstr($host,”google”))
{
Print(“Looking for $keyword? You will find more $keyword information here.”);
}
?>
If you get stuck let me know in the comments.
Posted in Weekend Projects | | | Digg This | del.icio.us | Technorati
Related Topics:
Weekend Projects: Adding Keywords
Wordpress Wednesdays: Improve SEO with Optimal Title Plug-In
Weekend Projects: How to Make Money with Twitter
Wordpress Wednesdays: Search Engine Optimization for Dummies
Top 10 Weekend Projects of 2008
1 Comment
Sorry, the comment form is closed at this time.
Great tips! There’s also a handy WordPress plugin that can do things like this: Who Sees Ads.