2 Replies - 1222 Views - Last Post: 10 June 2010 - 01:11 PM Rate Topic: -----

#1 Andy M  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 09-June 10

[Release] Notify me when Google redirects a visitor to my website

Posted 10 June 2010 - 12:03 PM

This is a simple PHP script, that can be very useful.
Basically you will receive and email when Google directs a guest/ visitor to your website.
Perhaps someone can expand on the script, as any other add-ons would be very useful I presume.

This script is for anyone who uses Google Adsense perhaps in their websites, but it is useful..

<?php
/* @author    Andy M/ xplosion
   @script    Email me  when Google directs a visitor to my website!
*/
$name=""; // Add you Name here..
$email_address=""; // email address you want the emails sent to.
$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 viewed your site after searching for '$keywords'. ($referrer)";

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

}
?>


Please comment, I would love for someone to give me ideas, or help me expand on it.

UPDATE #1 (Just took away double quotes)

This post has been edited by Andy M: 10 June 2010 - 01:13 PM


Is This A Good Question/Topic? 0
  • +

Replies To: [Release] Notify me when Google redirects a visitor to my website

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2988
  • Posts: 10,323
  • Joined: 08-August 08

Re: [Release] Notify me when Google redirects a visitor to my website

Posted 10 June 2010 - 12:55 PM

You could keep a list of those who've been referred and send it when the number of people is greater than a predefined number. This way you don't end up with 100 emails for 100 visits!

Oh, and there's no need to put the variables inside double quotes in the mail() function.
        mail ("$email_address","Google referred a visitor!","$email_message");
 ==
        mail ($email_address,"Google referred a visitor!",$email_message);


This post has been edited by CTphpnwb: 10 June 2010 - 12:57 PM

Was This Post Helpful? 3
  • +
  • -

#3 Andy M  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 14
  • Joined: 09-June 10

Re: [Release] Notify me when Google redirects a visitor to my website

Posted 10 June 2010 - 01:11 PM

Thanks for the feedback, I will update the code soon.
Yes, instead of getting 100 emails, true..

Thanks again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1