I thought I’d post this code I use on some of my sites. Basically when someone finds your site from another site it emails you and tells you where they came from. I know stats software is much more powerful but this is quite nice as it’s in real time.
if( !empty( $_SERVER[ “HTTP_REFERER” ] ) && substr_count( $_SERVER[ “HTTP_REFERER” ], “www.yourdomain” ) == 0 ) {
    $subject = “Someone has found YOUR WEBSITE NAME HERE”;
    $m = $_SERVER[ “HTTP_REFERER” ] . “\n” . $_SERVER[ “REQUEST_URI” ] . “\n”;
    $m .= “\n\nMessage sent on ” . date( “H:i:s, d/m/Y” );
    $headers = “From: Your website name <contact@yourdomain.com> Reply-To: Your website name <contact@yourdomain.com>n”;
    $to = “youremail@yourdomain.com”;
    mail( $to, $subject, $m, $headers );