Cookie concent feature.
This commit is contained in:
parent
39031274e8
commit
79b366cb18
1 changed files with 236 additions and 6 deletions
|
|
@ -3,16 +3,29 @@
|
|||
* A JavaScript file for analytic tracking.
|
||||
*/
|
||||
|
||||
var cookieConsent = {{ .Site.Params.cookieConsent | default false }};
|
||||
|
||||
var idSite = '{{ .Site.Params.piwikSiteID }}';
|
||||
var matomoTrackingApiUrl = 'https://{{ .Site.Params.piwikTrackerUrl }}/matomo.php';
|
||||
|
||||
var _paq = window._paq || [];
|
||||
if (cookieConsent) {
|
||||
_paq.push(['requireConsent']);
|
||||
}
|
||||
_paq.push(['setTrackerUrl', matomoTrackingApiUrl]);
|
||||
_paq.push(['setSiteId', idSite]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
if (typeof window.Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') {
|
||||
_paq.push(['setConsentGiven']);
|
||||
}
|
||||
|
||||
var googleAnalytics = '{{ .Site.GoogleAnalytics }}';
|
||||
if (cookieConsent) {
|
||||
if (typeof window.Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') {
|
||||
window['ga-disable-' + googleAnalytics] = true;
|
||||
}
|
||||
}
|
||||
|
||||
var _gaq = window._gaq || [];
|
||||
_gaq.push(['_setAccount', googleAnalytics]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue