You are here

function hotjar_page_attachments in Hotjar 8.2

Same name and namespace in other branches
  1. 8 hotjar.module \hotjar_page_attachments()

Implements hook_page_attachments().

Insert JavaScript to the <head> tag of the page.

File

./hotjar.module, line 36
Drupal Module: Hotjar.

Code

function hotjar_page_attachments(array &$attachments) {

  /** @var \Drupal\hotjar\SnippetAccessInterface $access */
  $access = \Drupal::service('hotjar.access');
  if (!$access
    ->check()) {
    return;
  }

  /** @var \Drupal\hotjar\SnippetBuilderInterface $snippet */
  $snippet = \Drupal::service('hotjar.snippet');
  $snippet
    ->pageAttachment($attachments);
}