Create popup for cookie consent
This commit is contained in:
parent
de005b7791
commit
1be6b82419
5 changed files with 79 additions and 28 deletions
24
layouts/partials/matomo_cookie_popup.html
Normal file
24
layouts/partials/matomo_cookie_popup.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{ if and (isset .Site.Params "matomo") (eq .Site.Params.matomo.enable true) }}
|
||||
<script type="text/javascript">
|
||||
window.addEventListener("load", function() {
|
||||
t=Matomo.getTracker("{{- .Site.Params.matomo.url -}}", "{{- .Site.Params.matomo.id -}}");
|
||||
when = t.getRememberedCookieConsent();
|
||||
|
||||
banner = document.getElementsByClassName("cookie-banner")[0];
|
||||
if (when == 0) {
|
||||
banner.style.display = 'block';
|
||||
}
|
||||
}, false);
|
||||
|
||||
function dismissPopup() {
|
||||
t=Matomo.getTracker("{{- .Site.Params.matomo.url -}}", "{{- .Site.Params.matomo.id -}}");
|
||||
t.rememberCookieConsentGiven()
|
||||
banner = document.getElementsByClassName("cookie-banner")[0];
|
||||
banner.style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
<div class="cookie-banner" style="display:none">
|
||||
<p>{{ i18n "popupMsg" }}<a href="{{- .Site.Params.matomo.policyurl -}}"> <u>{{ i18n "cookiePolicy" }}</u></a>.</p>
|
||||
<a style="font-size: 12px;" href="javascript:dismissPopup()">({{ i18n "dismissPopup" }})</a>
|
||||
</div>
|
||||
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue