-
Notifications
You must be signed in to change notification settings - Fork 0
/
consentMode.html
85 lines (76 loc) · 3.76 KB
/
consentMode.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="snifftegist" content="https://snifftegist.com/consentmode">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="max-snippet:-1">
<title>Document</title>
<link rel="stylesheet" href="index.css">
</head>
<div class="consent-container">
<div id="cookie-consent-banner" class="cookie-consent-banner">
<img id="logo" title="snifftegist" src="images/snifftegistlogo.png" alt="snifftegistlogo.png" width="20"
height="20">
<h3>Cookie settings</h3>
<p>SniffTegist uses cookie to provide the best of experience for our visitors.</p>
<button id="btn-accept-all" class="cookie-consent-button btn-success">Accept All</button>
<button id="btn-accept-some" class="cookie-consent-button btn-outline">Accept Selection</button>
<button id="btn-reject-all" class="cookie-consent-button btn-never">Reject All</button>
<div class="cookie-consent-options">
<label for="btn-accept-some"><input id="consent-necessary" type="checkbox"
value="Necessary">Necessary</label>
<label for="btn-accept-some"><input id="consent-analytics" type="checkbox"
value="Analytics">Analytics</label>
<label for="btn-accept-some"><input id="consent-preferences" type="checkbox"
value="Preferences">Preferences</label>
<label for="btn-accept-some"><input id="consent-marketing" type="checkbox"
value="Marketing">Marketing</label>
</div>
</div>
<script>
function hideBanner() { document.getElementById('cookie-consent-banner').style.display = 'none'; }
if (localStorage.getItem('consentMode') === null) {
document.getElementById('btn-accept-all').addEventListener('click', function () {
setConsent({
necessary: true,
analytics: true,
preferences: true,
marketing: true,
});
hideBanner();
});
document.getElementById('btn-accept-some').addEventListener('click', function () {
setConsent({
necessary: true,
analytics: document.getElementById('consent-analytics').checked,
preferences: document.getElementById('consent-preferences').checked,
marketing: document.getElementById('consent-marketing').checked,
});
hideBanner();
});
document.getElementById('btn-reject-all').addEventListener('click', function () {
setConsent({
necessary: false,
analytics: false,
preferences: false,
marketing: false,
});
hideBanner();
});
document.getElementById('cookie-consent-banner').style.display = 'block';
}
function setConsent(consent) {
const consentMode = {
'functionality_storage': consent.necessary ? 'granted' : 'denied',
'security_storage': consent.necessary ? 'granted' : 'denied',
'ad_storage': consent.marketing ? 'granted' : 'denied',
'analytics_storage': consent.analytics ? 'granted' : 'denied',
'personalization_storage': consent.preferences ? 'granted' : 'denied',
};
gtag('consent', 'update', consent);
localStorage.setItem('consentMode', JSON.stringify(consentMode));
}
</script>
</div>
</html>