You do not need to hide the GDPR efforts from Google at all. If at all, it is an excellent signal towards any search engine that you are law abiding and you have Privacy Policy in place and take Data Protection serious.
Your banner consists of 15 words - it doesn’t dilute anything. Besides, good SEO means that you are optimising for your User, not for the Search Engine (Google not only agrees with this statement but embraces it).
If you feel hiding the banner, you can do this by Querying the user agent - her a few examples depending on CMS, or Web Application Framework:
Ruby-on-Rails:
request.env["HTTP_USER_AGENT"]
Django:
from django.test import RequestFactory, TestCase
from utils import is_google_bot
class IsGoogleBotTestCase(TestCase):
def setUp(self):
self.factory = RequestFactory()
self.ua_google_bot = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
def create_request(self, ip=None, ua=None):
request = self.factory.get('/')
if ua:
request.META['HTTP_USER_AGENT'] = ua
if ip:
request.META['REMOTE_ADDR'] = ip
return request
def test_is_google_bot(self):
r = self.create_request('66.249.66.1', self.ua_google_bot) # google bot ip address comes from https://support.google.com/webmasters/answer/80553?hl=en
self.assertTrue(is_google_bot(r))
r = self.create_request('127.0.0.1', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 ')
self.assertFalse(is_google_bot(r))
PHP:
<?php
$crawlers = array(
'Google'=>'Google',
'Scrubby robot'=> 'Scrubby',
// ...
);
function crawlerDetect($USER_AGENT)
{
// to get crawlers string used in function uncomment it
// it is better to save it in string than use implode every time
// global $crawlers
// $crawlers_agents = implode('|',$crawlers);
$crawlers_agents = 'Google|Scrubby';
if ( strpos($crawlers_agents , $USER_AGENT) === false )
return false;
// crawler detected
// you can use it to return its name
/*
else {
return array_search($USER_AGENT, $crawlers);
}
*/
}
// example
$crawler = crawlerDetect($_SERVER['HTTP_USER_AGENT']);
if ($crawler )
{
// it is crawler, it's name in $crawler variable
}
else
{
// usual visitor
}
PS: It does not account as cloaking as it doesn’t make any difference to Google - remember you won’t win anything nor lose anything by hiding the banner - ergo: pointless exercise that only increases cost without any valuable contribution towards your SEO efforts.