forked from drnickyoung/gdpr-cookie-notice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·93 lines (74 loc) · 4.85 KB
/
index.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
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>GDPR Cookie Notice</title>
<link rel="stylesheet" type="text/css" href="dist/demo.css" />
<link rel="stylesheet" type="text/css" href="dist/style.css" />
</head>
<body>
<main>
<section id="getting-started" class="section-tertiary">
<div class="container container-small">
<h3>GDPR Cookie Notice</h3>
<p>This is a javascript solution built for nold.io to show a gdpr compliant cookie notice on your website. An example runs on this page, so you can play around with it.</p>
<h3>Getting started</h3>
<p>You can download the script from <a href="https://github.com/passatgt/gdpr-cookie-notice">Github</a>.</p>
<strong>Include the CSS and Javascript files:</strong>
<pre class="language-html"><code class="language-html"><script type="text/javascript" src="/gdpr-cookie-notice/dist/script.js"></script></code></pre>
<pre class="language-html"><code class="language-html"><link rel="stylesheet" type="text/css" href="/gdpr-cookie-notice/dist/style.css" /></code></pre>
<strong>Init the plugin with the following config file</strong>
<pre class="language-javascript"><code class="language-javascript">gdprCookieNotice({
locale: 'en', //This is the default value
timeout: 500, //Time until the cookie bar appears
expiration: 30, //This is the default value, in days
domain: '.nold.io', //If you run the same cookie notice on all subdomains, define the main domain starting with a .
implicit: true, //Accept cookies on scroll
statement: 'https://google.com', //Link to your cookie statement page
performace: ['JSESSIONID'], //Cookies in the performance category.
analytics: ['ga'], //Cookies in the analytics category.
marketing: ['SSID'] //Cookies in the marketing category.
});</code></pre>
<p>Now the notice will be visible on page load at the bottom of the screen. Clicking on cookie settings will display a modal window, with 4 cookie categories: essential, performance, analytics and marketing. Everything is checked by default. Cookies listed in the config file for each category will be deleted on page load, if user is opted our from a specific category.</p>
<p><strong>Loading scripts after the cookies are enabled</strong></p>
<p>You can listen to the javascript event called gdprCookiesEnabled to load scripts only when the cookies are enabled by the user. For example, to load a specific tracking tool like a Facebook pixel, wrap its code like so:</p>
<pre class="language-javascript"><code class="language-javascript"><script type="text/javascript">
document.addEventListener('gdprCookiesEnabled', function (e) {
if(e.detail.marketing) { //checks if marketing cookies are enabled
//code here when marketing cookies are enabled
}else{
//code here when marketing cookies are disabled
}
});
</script></code></pre>
<p><strong>How can i translate the plugin?</strong></p>
<p>Duplicate the src/langs/en.js file, rename it, translate it and include it before your configuration runs. Define the locale name in the locale parameter.</p>
<p><strong>Is this totally GDPR compatible?</strong></p>
<p>It works for us, might not work for you. I don't know, i'm not a lawyer.</p>
<p><img src="https://i.imgur.com/oA6KO7f.gif" /></p>
<p><strong>How can i include a button to show the cookie settings modal?</strong>
<p>Simply add the classname 'gdpr-cookie-notice-settings-button' to any element, like <a href="#" class="gdpr-cookie-notice-settings-button">this</a>.</p>
<p><strong>How can i change the colors and stuff?</strong>
<p>Well, its just css, so you could overwrite the styles in your own css files. OR, run <code>npm install</code>, edit the sass variables at the top of <code>src/sass/_gdpr-cookie-notice.scss</code> and run <code>gulp</code> to generate the new files in the <code>src</code> folder which you can preview by going to <code>localhost:3000</code> in your browser.</p>
</div>
</section>
</main>
<script src="dist/script.js" type="text/javascript"></script>
<script>
gdprCookieNotice({
statement: '/cookies',
performace: ['JSESSIONID'],
analytics: ['_gat', 'ga'],
marketing: ['SSID']
});
</script>
<script type="text/javascript">
document.addEventListener('gdprCookiesEnabled', function (e) {
console.log(e);
if(e.detail.marketing) {
console.log('marketing cookies are enabled');
}
});
</script>
</body>
</html>