![]() | | ||||||||
| | #1 |
| Lisa Dozois War Room Member Join Date: Jan 2006 Location: Florida, USA.
Posts: 612
Thanks: 85
Thanked 221 Times in 110 Posts
|
From time to time I like to get instant notification when my site is visited. I do this especially on landing pages when I first start promoting them. I do it all the time on my freelance portfolio site so I can see when people are checking me out. It's not an elegant solution but it works for me. It might be something you would want to use, so here it is. It's in PHP. Just install it at the top of your index.php, after any include file statements, or add it to your config.php. // send the admin an email // Remember to change the values for $sitename and $admin_email! $ttime = date("F j, Y, g:i a"); $sitename = 'Your site name goes here'; $admin_email = 'youremail@address.com'; $ip = getip(); $host = gethostbyaddr($ip); //Native PHP function $origin = $_SERVER['HTTP_REFERER']; if (empty($origin)){$origin = 'an unknown link ';} $message = "A visitor from $host ($ip) visited via $origin at $ttime."; $subject = "New visitor to $sitename"; mail($admin_email,$subject,$message); function getip() { if (isSet($_SERVER)) { if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) { $realip = getenv( 'HTTP_X_FORWARDED_FOR' ); } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) { $realip = getenv( 'HTTP_CLIENT_IP' ); } else { $realip = getenv( 'REMOTE_ADDR' ); } } return $realip; } |
|
-- Lisa G
| |
| | |
| | #2 |
| Active Warrior Join Date: Aug 2009
Posts: 31
Thanks: 19
Thanked 3 Times in 3 Posts
|
Thanks for sharing! I'm going to use this on a couple of my sites..
|
| How to Set Up a Website Using WordPress Step-by-step! ->PLR rights included!<- WordPress PLR eBook Your Article Service: Article Writing, Spinning, Submission and Article to Video Creation Services. | |
| | |
| | #3 |
| Webweaver Join Date: Aug 2009
Posts: 119
Thanks: 4
Thanked 2 Times in 2 Posts
|
Its working well for me thanks for sharing good work |
| | |
| | |
| | #4 |
| A Writer, Naturally War Room Member Join Date: Jan 2007 Location: The Scotsman in Spain.
Posts: 240
Thanks: 12
Thanked 22 Times in 20 Posts
|
Thank you Lisa G, I have a few totally new sites to which I can apply this and monitor the activity. Regards Andrew G. |
| | |
| | |
| | #5 |
| HyperActive Warrior Join Date: Jul 2009
Posts: 186
Thanks: 4
Thanked 24 Times in 20 Posts
|
This is great, the script mails you when a visitor lands on your page. You can get even more stats (real time web stats) by using whos.amung.us/ (free instantly see where your visitors are from) For more advanced real time tracking including mouse movements of visitors there is this site: clixpy.com |
| | |
| | |
| | #6 |
| Lisa Dozois War Room Member Join Date: Jan 2006 Location: Florida, USA.
Posts: 612
Thanks: 85
Thanked 221 Times in 110 Posts
|
I updated the code to replace the missing statement that adds the date and time of the visit to the email. So if you are running the script and your notification email message ends with "at" and no date and time, just recopy the code at the top of this thread and reinstall. |
|
-- Lisa G
| |
| | |
![]() |
|
| Tags |
| dirty, hit, notifier, quick |
| Thread Tools | |
| |
![]() |