Jump to content

Recommended Posts

I've received help in solving PHP problems in these forums in the past so I thought I'd give a little something back. Hopefully this is the correct forum to do so?

 

I wanted to receive an email when Google directs anyone to my site to tell me what keywords they have used to find my site.

 

A very basic and useful script, hopefully it can be of use to someone or maybe to expand on.

 

<?php
// Script to email you when Google refers traffic to your site.
$name=""; // add your name here
$email_address=""; // add your email address here
$keywords="";
$referrer=$_SERVER['HTTP_REFERER'];

if( (stristr($referrer, "google")) && (stristr($referrer, "search")) ) {

parse_str($referrer, $output);
$keywords=$output['q'];

$email_message="Hi $name, A visitor just arrived to your site after searching for '$keywords'. ($referrer)";

mail ("$email_address","Google referred a visitor","$email_message");

}
?>

 

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.