-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathexample_gdpr.html
104 lines (93 loc) · 4.24 KB
/
example_gdpr.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
94
95
96
97
98
99
100
101
102
103
104
<html>
<head>
<!-- Page styling here -->
<link rel='stylesheet' type='text/css' href='./style/style.css'>
<!--Countly script-->
<script type='text/javascript' src='../lib/countly.js'></script>
<script type='text/javascript'>
//initializing countly with params and passing require_consent config as true
const COUNTLY_SERVER_KEY = "https://your.server.ly";
const COUNTLY_APP_KEY = "YOUR_APP_KEY";
if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
console.warn("Please do not use default set of app key and server url")
}
// initializing countly with params
Countly.init({
app_key: COUNTLY_APP_KEY,
url: COUNTLY_SERVER_KEY, //your server goes here
debug: true,
require_consent: true //this true means consent is required
});
//(optionally) provide custom feature tree if needed
Countly.group_features({
activity: ["sessions", "events", "views"],
interaction: ["scrolls", "clicks", "forms"]
});
//we can call all the helper methods we want, they won't record until consent is provided for specific features
Countly.track_sessions();
Countly.track_pageview();
Countly.track_clicks();
Countly.track_links();
Countly.track_forms();
Countly.track_errors({ jquery: "1.10", jqueryui: "1.10" });
//Consent Management logic should be implemented and controled by developer
//this is just a simply example of what logic it could have
if (typeof (localStorage) !== "undefined") {
var consents = localStorage.getItem("consents");
//checking if user already provided consent
if (consents) {
//we already have array with consents from previous visit, let's just pass them to Countly
Countly.add_consent(JSON.parse(consents));
}
else {
//user have not yet provided us a consent
//we need to display popup and ask user to give consent for specific features we want to track
//for example purposes, we will wait till user clicks "Give Consent" button
//to allow consent for "activity", "interaction", "crashes"
}
} else {
// Sorry! No Web Storage support..
// we can fallback to cookie
}
//user can then change his mind and opt out or opt back in
//so let's provide these function to UI
function giveConsent() {
//give consent to same 3 features
var response = ["activity", "interaction", "crashes"];
Countly.add_consent(response);
localStorage.setItem("consents", JSON.stringify(response));
}
function removeConsent() {
//remove consent from same 3 features
var response = ["activity", "interaction", "crashes"];
Countly.remove_consent(response);
localStorage.setItem("consents", JSON.stringify([]));
}
</script>
</head>
<body>
<!-- Header, banner etc. Top part of your site -->
<div id="header">
<h1>GDPR Features</h1>
<img id="logo" src="./images/logo.png">
</div>
<center>
<img src="./images/team_countly.jpg" id="wallpaper" />
<form method='post' name='comments' onsubmit="return false;">
<p><input type="text" name="message" value="Message Name"></p>
<p><textarea>Message</textarea></p>
<p><select>
<option value='option1'>Option1</option>
<option value='option2'>Option2</option>
<option value='option3'>Option3</option>
</select></p>
<p><input id="submit-form" type="submit" value="Submit"></p>
</form>
<p><button id="unhandled_error" onclick="unhandled_error()">Unhandled Error</button></p>
<p><a id="track_link" href='#link'>Dummy link</a></p>
<p><a href='https://countly.com/'>Countly</a></p>
<p><button onclick="giveConsent()">Give Consent</button></p>
<p><button onclick="removeConsent()">Remove Consent</button></p>
</center>
</body>
</html>