This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
forked from keen/auto-collector-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.html
207 lines (187 loc) · 6.64 KB
/
forms.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Keen IO Auto-Collector Dashboard</title>
<link rel="shortcut icon" href="https://keen.io/assets/images/favicon.ico"/>
<!-- CSS -->
<link rel="stylesheet" href="./assets/keen-dashboards.css" />
<link rel="stylesheet" href="./assets/demo-styles.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://d26b395fwzu5fz.cloudfront.net/keen-dataviz-1.1.3.min.css">
<!-- THEMES -->
<link rel="stylesheet" href="./themes/dashboard.css" />
<!-- JS -->
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.3.min.js"></script>
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-dataviz-1.1.3.min.js"></script>
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-analysis-1.2.2.js"></script>
<!-- Keen IO Setttings -->
<script src="./settings.js"></script>
<script type="text/javascript">
function createKeenWebAutoCollector(){window.keenWebAutoCollector=window.KeenWebAutoCollector.create({projectId:'58f5422295cfc9addc2473d3',writeKey:'F5120F951F5B55E1DBAE60A583B23A5B94FFCA6822435187C05DB63CECE6803689FE10E8A3D90B889C8950D23E18CCA60A0FF346BF76A20D0DE59975927B2181AD6500D53BB2AA8E31E1CB0CFF31EB4B457CA4DC2E39051C4400FF19273CE009',onloadCallbacks:window.keenWebAutoCollector.onloadCallbacks}),window.keenWebAutoCollector.loaded()}function initKeenWebAutoCollector(){window.keenWebAutoCollector.domReady()?window.createKeenWebAutoCollector():document.addEventListener("readystatechange",function(){window.keenWebAutoCollector.domReady()&&window.createKeenWebAutoCollector()})}window.keenWebAutoCollector={onloadCallbacks:[],onload:function(a){this.onloadCallbacks.push(a)},domReady:function(){return["ready","complete"].indexOf(document.readyState)>-1}};
</script>
<script async type="text/javascript" src="https://d26b395fwzu5fz.cloudfront.net/keen-web-autocollector-1.0.8.min.js" onload="initKeenWebAutoCollector()"></script>
</head>
<body class="demo-theme-dashboard" onload="settings()">
<div class="container">
<h1>
Keen IO Auto-Collector Dashboard
<a href="https://glitch.com/edit/#!/remix/auto-collector-dashboard"><img src="https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button.svg" alt="Remix on Glitch" /></a>
</h1>
<nav>
<ul class="nav nav-tabs">
<li role="presentation"><a href="./index.html">Pageviews</a></li>
<li role="presentation"><a href="./clicks.html">Clicks</a></li>
<li role="presentation" class="active"><a href="./forms.html">Forms</a></li>
<li role="presentation"><a href="https://github.com/keen/auto-collector-dashboard">Source Code on Github</a></li>
</ul>
</nav>
<h3 id="timeframe"></h3>
<div class="keen-ui-row">
<div class="keen-ui-col-8">
<div class="forms-interval"></div>
</div>
<div class="keen-ui-col-4">
<div class="total-forms"></div>
</div>
</div>
<div>
<div class="keen-ui-col-8">
<div class="forms-by-id-interval"></div>
</div>
<div class="keen-ui-col-4">
<div class="forms-by-id"></div>
</div>
</div>
</div>
<script>
window.renderCharts = function(client, timeframe) {
document.getElementById("timeframe").innerHTML="timeframe: " + timeframe.replace(/_/g, ' ');
var formsInterval = new Dataviz()
.el('.forms-interval')
.height(300)
.type('line')
.chartOptions({
axis: {
y: {
padding: {bottom:0}
}
}
})
.title('Forms Submitted')
.render();
client
.query('count', {
event_collection: "form_submissions",
interval: "daily",
timeframe: timeframe,
timezone: "UTC"
})
.then(function(res){
// Handle the result
formsInterval
.data(res)
.render();
})
.catch(function(err){
// Handle the error
formsInterval
.message(err.message);
});
var forms = new Dataviz()
.height(280)
.el('.total-forms')
.type('metric')
.title('Forms Submitted')
.prepare();
client
.query('count', {
event_collection: 'form_submissions',
timeframe: timeframe,
timezone: 'UTC'
})
.then(function(res){
// Handle the result
forms
.data(res)
.render();
})
.catch(function(err){
// Handle the error
forms
.message(err.message);
});
var formsByIdInterval = new Dataviz()
.el('.forms-by-id-interval')
.height(300)
.type('line')
.chartOptions({
axis: {
y: {
padding: {bottom:0}
}
}
})
.title('Forms Submitted By Element.ID')
.render();
client
.query('count', {
event_collection: "form_submissions",
interval: "daily",
group_by: [
"element.id"
],
timeframe: timeframe,
timezone: "UTC"
})
.then(function(res){
// Handle the result
formsByIdInterval
.data(res)
.render();
})
.catch(function(err){
// Handle the error
formsByIdInterval
.message(err.message);
});
var formsById = new Dataviz()
.el('.forms-by-id')
.height(300)
.type('pie')
.title('Forms Submitted By Element.ID')
.render();
client
.query('count', {
event_collection: "form_submissions",
group_by: [
"element.id"
],
timeframe: timeframe,
timezone: "UTC"
})
.then(function(res){
// Handle the result
formsById
.data(res)
.render();
})
.catch(function(err){
// Handle the error
formsById
.message(err.message);
});
function rand(a, b){
return Math.floor((Math.random() * b) + a);
}
function gen(n){
var arr = [ faker.internet.exampleEmail() ];
for (var i = 0; i < n; i++) {
arr.push(rand(0, 1000));
}
return arr;
}
}
</script>
</body>
</html>