-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Pablo Tamarit <pablo.tamarit@cern.ch> Co-authored-by: Alex Ioannidis <a.ioannidis@cern.ch>
- Loading branch information
1 parent
e49a022
commit 3df3621
Showing
4 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 69 additions & 5 deletions
74
templates/semantic-ui/zenodo_rdm/trackingcode/trackingcode-prod.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,79 @@ | ||
<!-- Matomo --> | ||
<div class="ui container info message cookie-banner hidden"> | ||
<i class="close icon"></i> | ||
<div> | ||
<i aria-hidden="true" class="info icon"></i> | ||
<p class="inline">This site uses cookies. Find out more on <a href="{{ _(config.COOKIE_POLICY_URL) }}">how we use cookies</a></p> | ||
</div> | ||
<div class="buttons"> | ||
<button class="ui button small primary" id="cookies-all">Accept all cookies</button> | ||
<button class="ui button small" id="cookies-essential">Accept only essential cookies</button> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var _paq = window._paq = window._paq || []; | ||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | ||
_paq.push(['trackPageView']); | ||
_paq.push(['enableLinkTracking']); | ||
_paq.push(['requireCookieConsent']); | ||
|
||
(function() { | ||
var u="https://webanalytics.web.cern.ch/"; | ||
_paq.push(['setTrackerUrl', u+'matomo.php']); | ||
_paq.push(['setSiteId', '366']); | ||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; | ||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); | ||
})(); | ||
|
||
const cookieConsent = document.cookie | ||
.split("; ") | ||
.find((row) => row.startsWith("cookie_consent=")) | ||
?.split("=")[1]; | ||
|
||
if (cookieConsent) { | ||
if (cookieConsent === "all") { | ||
matomo(); | ||
} | ||
} else { | ||
document.querySelector(".cookie-banner").classList.remove("hidden") | ||
_paq.push(['forgetConsentGiven']); | ||
} | ||
|
||
$('.cookie-banner .close') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","essential"); | ||
}); | ||
|
||
$('#cookies-essential') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","essential"); | ||
}); | ||
|
||
$('#cookies-all') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","all"); | ||
_paq.push(['rememberCookieConsentGiven']); | ||
matomo(); | ||
}); | ||
|
||
function matomo() { | ||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | ||
_paq.push(['trackPageView']); | ||
_paq.push(['enableLinkTracking']); | ||
} | ||
|
||
function setCookie(cname, cvalue) { | ||
var d = new Date(); | ||
d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); // one year | ||
var expires = "expires=" + d.toUTCString(); | ||
var cookie = cname + "=" + cvalue + ";" + expires + ";" | ||
cookie += "path=/;SameSite=None; Secure"; // so that it works across subdomains | ||
document.cookie = cookie; | ||
} | ||
</script> | ||
<!-- End Matomo Code --> |
86 changes: 75 additions & 11 deletions
86
templates/semantic-ui/zenodo_rdm/trackingcode/trackingcode-qa.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,79 @@ | ||
<!-- Matomo --> | ||
<div class="ui container info message cookie-banner hidden"> | ||
<i class="close icon"></i> | ||
<div> | ||
<i aria-hidden="true" class="info icon"></i> | ||
<p class="inline">This site uses cookies. Find out more on <a href="{{ _(config.COOKIE_POLICY_URL) }}">how we use cookies</a></p> | ||
</div> | ||
<div class="buttons"> | ||
<button class="ui button small primary" id="cookies-all">Accept all cookies</button> | ||
<button class="ui button small" id="cookies-essential">Accept only essential cookies</button> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var _paq = window._paq = window._paq || []; | ||
var _paq = window._paq = window._paq || []; | ||
_paq.push(['requireCookieConsent']); | ||
|
||
(function() { | ||
var u="https://webanalytics.web.cern.ch/"; | ||
_paq.push(['setTrackerUrl', u+'matomo.php']); | ||
_paq.push(['setSiteId', '365']); | ||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; | ||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); | ||
})(); | ||
|
||
const cookieConsent = document.cookie | ||
.split("; ") | ||
.find((row) => row.startsWith("cookie_consent=")) | ||
?.split("=")[1]; | ||
|
||
if (cookieConsent) { | ||
if (cookieConsent === "all") { | ||
matomo(); | ||
} | ||
} else { | ||
document.querySelector(".cookie-banner").classList.remove("hidden") | ||
_paq.push(['forgetConsentGiven']); | ||
} | ||
|
||
$('.cookie-banner .close') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","essential"); | ||
}); | ||
|
||
$('#cookies-essential') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","essential"); | ||
}); | ||
|
||
$('#cookies-all') | ||
.on('click', function () { | ||
$(this) | ||
.closest('.message') | ||
.transition('fade'); | ||
setCookie("cookie_consent","all"); | ||
_paq.push(['rememberCookieConsentGiven']); | ||
matomo(); | ||
}); | ||
|
||
function matomo() { | ||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ | ||
_paq.push(['trackPageView']); | ||
_paq.push(['enableLinkTracking']); | ||
(function() { | ||
var u="https://webanalytics.web.cern.ch/"; | ||
_paq.push(['setTrackerUrl', u+'matomo.php']); | ||
_paq.push(['setSiteId', '365']); | ||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; | ||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); | ||
})(); | ||
</script> | ||
<!-- End Matomo Code --> | ||
} | ||
|
||
function setCookie(cname, cvalue) { | ||
var d = new Date(); | ||
d.setTime(d.getTime() + (365 * 24 * 60 * 60 * 1000)); // one year | ||
var expires = "expires=" + d.toUTCString(); | ||
var cookie = cname + "=" + cvalue + ";" + expires + ";" | ||
cookie += "path=/;SameSite=None; Secure"; // so that it works across subdomains | ||
document.cookie = cookie; | ||
} | ||
</script> |