Jump to content

Receive and email when google refers a visitor part 2.


chrismarsden

Recommended Posts

Hi, didnt know how to add this to the repository so can an admin move this please.

 

this updated version will tell you still when you recieve a visitor but to identify who i have included so that it tracks the ip and tells you when its you!!!

 

<?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'];

$known_ips = array(
    '01.01.01.01' => 'from the computer your are at now!',
    // etc.
);

$ip = $_SERVER['REMOTE_ADDR'];

if (array_key_exists($ip, $known_ips))
{
    $ip = $known_ips[$ip];
    // you may want to use a different var name here now?
}



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

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

   $email_message="A visitor just arrived to the website after searching for '$keywords', Their IP address is '$ip'. ($referrer)";

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

 

 

hope it all works... give it a try and let me know.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.