Search code examples
searchsearch-enginegoogle-indexsearch-engine-bots

Disable google indexing website telephone numbers


I was presented with the task of hiding telephone numbers from Google - what that means is, we want to display them on the website and have them clickable href="tel:..." but to ensure Google does not index it and does NOT display it with the search results.

Does anyone know of any effective technique? I was thinking of writing VueJs component, which mixes given number with some alpha characters, but this would only work with the presentation / label, the tel:... would still have to have a valid telephone number and I'm not sure if Google wouldn't pick it form the href attribute.


Solution

  • I think the best approach is just to hide it from bots, may be you can use something like this VueIfBot

    <vue-if-bot>
    <a href="tel: ...">This will not be visible for bots</a>
    </vue-if-bot>
    

    or any other alternative just check the userAgent for example in php

    function _bot_detected() {
    
      return (
        isset($_SERVER['HTTP_USER_AGENT'])
        && preg_match('/bot|crawl|slurp|spider|mediapartners/i', $_SERVER['HTTP_USER_AGENT'])
      );
    }
    

    If you can't get userAgent, but you still want to check if this is a search engine crawler you can check user IP adress here is a list of IP Addresses of Search Engine Spiders

    And finally after you successfully hide your data you can test it with User-Agent Switcher