How tell if the current site visitor is really the Google indexing bot?

stgreenwalt
stgreenwalt used Ask the Experts™
on
Using javascript, is there a way to detect if the currect site visitor is the Google indexing bot?

If it's Google, then we will make sure that embedded video is delivered using the Html5 "video" tag, or the ancient "object" tag . . . but *not* an iframe tag.

If it's not Google, we'll display video according to whatever is best for the given device, platform, and video file type.  That could result in use of 'iframe' or other things that Google doesn't like.

Obviously we'll have a video map file as well.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Year 2014
Top Expert 2014
Commented:
You can try something like

if( navigator.userAgent.toLowerCase().indexOf('googlebot') > 0){
// Googlebot
}
Fixer of Problems
Most Valuable Expert 2014
Commented:
Google also does not like it when you put up special content for them that is different than what you server to other users.  https://support.google.com/webmasters/answer/66355
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
display video according to whatever is best for the given device,

That is all you need to worry about.    That google is smarter than you think. It is already out gaming your game.
Jeffrey Dake Senior Director of Technologyy
Commented:
To make sure you are serving google what they want the best way is to check the user agent, like Cathal stated.  Since the html is the same as you would be showing other users that are using devices that support the "video" tag then you are not really showing different content to google.  If you really need to verify that it is google you can always double check the ip addresses to see if they resolve to a known google bot ip address, but since all you are doing is switching the video tag vs an iframe, checking the user agent would probably be the best.  

Firefox has a plugin for User-Agent switcher so you can test the user agent coming in as googlebot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial