ga.module in Googalytics - Google Analytics 8
Contains ga.module.
File
ga.moduleView source
<?php
/**
* @file
* Contains ga.module.
*/
use Drupal\ga\AnalyticsEvents;
use Drupal\ga\Event\CollectEvent;
/**
* Implements hook_page_attachments().
*/
function ga_page_attachments(array &$attachments) {
// Don't execute until gacsp module is uninstalled.
if (\Drupal::moduleHandler()
->moduleExists('gacsp')) {
return;
}
/** @var \Drupal\ga\Event\CollectEvent $event */
$event = \Drupal::service('event_dispatcher')
->dispatch(AnalyticsEvents::COLLECT, new CollectEvent());
$commands = $event
->getDrupalSettingCommands();
if (!empty($commands)) {
$attachments['#attached']['library'][] = 'ga/analytics';
$attachments['#attached']['drupalSettings']['ga']['commands'] = $commands;
}
}
Functions
Name | Description |
---|---|
ga_page_attachments | Implements hook_page_attachments(). |