0

I want to hide a privacy policy banner from Google. A similar question has been asked over here however a lot has changed since then. In our case, we have been advised by our lawyers to ensure that this banner is shown to our users to help our compliancy with GDPR.

The banner I'm trying to hide from Google can be seen on the left. If hidden I would expect Google to see our website as shown on the right. enter image description here

I have two questions:

  1. Is it possible to do this without getting flagged for cloaking?
  2. Is there any "best practice" for this?
2
  • What’s the point of hiding the privacy banner from Google? I am intrigued … – Georg Keferböck Jul 4 '19 at 22:12
  • Because it would start to dilute the other key terms on your website that you actually want to rank for. – John Crawford Jul 5 '19 at 10:28
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.