Use localstorage for cookiconsent response instead of setting a cookie.
This commit is contained in:
parent
fec3d75d9c
commit
767119d014
1 changed files with 37 additions and 49 deletions
|
|
@ -5,26 +5,26 @@
|
|||
* A JavaScript file for analytic tracking.
|
||||
*/
|
||||
|
||||
var cookieConsent = {{ .Site.Params.cookieConsent | default false }};
|
||||
|
||||
var cookiebanner = {{ .Site.Params.cookieConsent | default false }};
|
||||
var cookieconsent = localStorage.getItem('cookieconsent');
|
||||
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 Cookies !== 'undefined' && Cookies.get('cookieconsent') === 'accept') {
|
||||
_paq.push(['setConsentGiven']);
|
||||
}
|
||||
|
||||
var googleAnalytics = '{{ .Site.GoogleAnalytics }}';
|
||||
if (cookieConsent) {
|
||||
if (typeof Cookies === 'undefined' || Cookies.get('cookieconsent') !== 'accept') {
|
||||
window['ga-disable-' + googleAnalytics] = true;
|
||||
|
||||
if (idSite) {
|
||||
var _paq = window._paq || [];
|
||||
if (cookiebanner) {
|
||||
_paq.push(['requireConsent']);
|
||||
}
|
||||
_paq.push(['setTrackerUrl', matomoTrackingApiUrl]);
|
||||
_paq.push(['setSiteId', idSite]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
if (cookiebanner && cookieconsent === 'accept') {
|
||||
_paq.push(['setConsentGiven']);
|
||||
}
|
||||
}
|
||||
|
||||
if (googleAnalytics && cookiebanner && cookieconsent === 'decline') {
|
||||
window['ga-disable-' + googleAnalytics] = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue