gortron Posted December 8, 2008 Share Posted December 8, 2008 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"); } ?> Link to comment https://forums.phpfreaks.com/topic/136089-receive-an-email-when-google-directs-a-visitor-to-your-site/ Share on other sites More sharing options...
Recommended Posts