You are here

function crazyegg_library_info_build in Crazy Egg Integration 8

Implements hook_library_info_build(). Includes Crazy Egg tracking script as a library (but doesn't insert it to the page yet)

File

./crazyegg.module, line 46

Code

function crazyegg_library_info_build() {
  $libs = [
    'crazyegg' => [],
  ];
  $account_path = crazyegg_get_account_path();
  if ($account_path) {
    $scope = \Drupal::config('crazyegg.settings')
      ->get('crazyegg_js_scope');
    $libs['crazyegg'] = [
      'header' => $scope === 'header',
      'js' => [
        'https://script.crazyegg.com/pages/scripts/' . $account_path . '.js' => [
          'type' => 'external',
          'minified' => TRUE,
          'weight' => 0,
          'attributes' => [
            'async' => TRUE,
          ],
        ],
      ],
    ];
  }
  return $libs;
}