Question about Google [bot]
Moderator: General Moderators
-
kingofnumbers
- Forum Newbie
- Posts: 6
- Joined: Thu Dec 23, 2010 9:35 pm
Question about Google [bot]
How do I know if Google [bot] visited a PHP page??
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Question about Google [bot]
Muddy footprints on the carpet?
No, seriously, I think that the best method is to use the user-agent strings of visitors. I think that google bots all have a user agent string which contains "Googlebot" or "googlebot", so something like this, included in the code for the page you want to monitor, should do what you want:
No, seriously, I think that the best method is to use the user-agent strings of visitors. I think that google bots all have a user agent string which contains "Googlebot" or "googlebot", so something like this, included in the code for the page you want to monitor, should do what you want:
Code: Select all
$visitor = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($visitor, 'googlebot'))
{
// do something eg write to a log file
}
-
kingofnumbers
- Forum Newbie
- Posts: 6
- Joined: Thu Dec 23, 2010 9:35 pm
Re: Question about Google [bot]
Thanks!
Re: Question about Google [bot]
or you can just look at your server logs and do a 'find' search for 'googlebot' if you do not want to create another set of logs.