protected function SnippetBuilder::pageAttachmentBuilt in Hotjar 8.2
Add page attachments when Build mode is in use.
1 call to SnippetBuilder::pageAttachmentBuilt()
- SnippetBuilder::pageAttachment in src/
SnippetBuilder.php - Implements hook_page_attachment().
File
- src/
SnippetBuilder.php, line 140
Class
- SnippetBuilder
- Snippet builder service.
Namespace
Drupal\hotjarCode
protected function pageAttachmentBuilt(array &$attachments) {
$uri = $this
->getSnippetPath();
$query_string = $this->state
->get('system.css_js_query_string') ?: '0';
$query_string_separator = strpos($uri, '?') !== FALSE ? '&' : '?';
$url = file_url_transform_relative(file_create_url($uri));
$attachments['#attached']['html_head'][] = [
[
'#type' => 'html_tag',
'#tag' => 'script',
'#attributes' => [
'src' => $url . $query_string_separator . $query_string,
],
],
'hotjar_script_tag',
];
}