diff --git a/config/vufind/config.ini b/config/vufind/config.ini index e1b155064eb2266ecafbd02a9586ee91bedac450..b69cf8ad8e0c23f7d119594b7b21c96cbdde047c 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1661,6 +1661,9 @@ treeSearchLimit = 100 ; the string, for example "SiteA|Backend|Search Terms." Most users will want to ; leave this disabled. ;searchPrefix = "SiteA|" +; Uncomment the following setting to disable cookies for privacy reasons. +; see https://matomo.org/faq/general/faq_157/ for more information. +;disableCookies = true ; Uncomment portions of this section to activate tabs in the search box for switching ; between search modules. Keys are search backend names, values are labels for use in diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php index 7ce3270573a6ec081ede17a9c601a20d0d449afc..b73e716e999d2ad8386f5ee1c3a188389d5d3788 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Piwik.php @@ -59,6 +59,13 @@ class Piwik extends \Zend\View\Helper\AbstractHelper */ protected $searchPrefix; + /** + * Whether to disable cookies (see config.ini for details) + * + * @var bool + */ + protected $disableCookies; + /** * Whether to track use custom variables to track additional information * @@ -123,6 +130,7 @@ class Piwik extends \Zend\View\Helper\AbstractHelper if (is_array($options)) { $this->siteId = $options['siteId']; $this->searchPrefix = $options['searchPrefix'] ?? ''; + $this->disableCookies = $options['disableCookies'] ?? ''; } else { $this->siteId = $options; } @@ -426,7 +434,7 @@ class Piwik extends \Zend\View\Helper\AbstractHelper protected function getOpeningTrackingCode() { $escape = $this->getView()->plugin('escapejs'); - return <<<EOT + $code = <<<EOT function initVuFindPiwikTracker{$this->timestamp}(){ var VuFindPiwikTracker = Piwik.getTracker(); @@ -436,6 +444,14 @@ function initVuFindPiwikTracker{$this->timestamp}(){ VuFindPiwikTracker.setCustomUrl('{$escape($this->getCustomUrl())}'); EOT; + if ($this->disableCookies) { + $code .= <<<EOT + VuFindPiwikTracker.disableCookies(); + +EOT; + } + + return $code; } /** diff --git a/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php b/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php index 2720a2d3b2f7e02f3b080a8165949fcf2172f54a..92eb3b1c78a1a447a1d92b03ec0229016ef67a73 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/PiwikFactory.php @@ -66,7 +66,8 @@ class PiwikFactory implements FactoryInterface $url = $config->Piwik->url ?? false; $settings = [ 'siteId' => $config->Piwik->site_id ?? 1, - 'searchPrefix' => $config->Piwik->searchPrefix ?? null + 'searchPrefix' => $config->Piwik->searchPrefix ?? null, + 'disableCookies' => $config->Piwik->disableCookies ?? false ]; $customVars = $config->Piwik->custom_variables ?? false; $request = $container->get('Request');