Add JS code to header tag of html

Reading docs about drupal_add_js you might think you can add JS to header of html, but only thing you can choose is header or footer of your theme (as region), to add JS to header tag, you need to use drupal_add_html_head  and add it like below, this is an example for simple script for cookiebot service

function my_module_preprocess_html(&$variables) {

  // Cookie bot JS
  $data = array(
    '#tag' => 'script',
    '#value' => '',
    '#attributes' => array(
      'id' => 'Cookiebot',
      'src' => url(''),
      'data-cbid' => 'dddfs66-71324d-421a-822-621125a3a80fe8',
      'async' => '',
  drupal_add_html_head($data, 'cookie_bot');