-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrealtime.html
231 lines (225 loc) · 19.4 KB
/
realtime.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Realtime Dashboard</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1">
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://gtm.vreeman.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WKSDWK');</script>
<style>
html {
overflow-y: scroll;
overflow-x: hidden;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 1% auto;
padding: 0 3%;
max-width: 30em;
font: 1.125em/1.6 BlinkMacSystemFont, -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
footer, small {
font-size: 80%;
}
b, dt, strong {
font-weight: 700;
}
h1, h2, h3 {
line-height: 1.2;
}
a {
background-color: transparent;
}
code {
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace;
font-size: 1em;
}
input, textarea {
width: 95%;
display: block;
padding: .5em 1%;
font-size: 1em;
}
fieldset, input, textarea {
margin-bottom: 1.5em;
}
textarea {
margin-top: 1.5em;
resize: vertical;
}
.ActiveUsers b {
color: black;
}
.is-increasing b {
color: green;
}
.is-decreasing b {
color: red;
}
</style>
<link rel="canonical" href="https://vreeman.com/">
<meta name="referrer" content="no-referrer">
<meta name="robots" content="noindex,follow">
</head>
<body>
<noscript><iframe src="https://gtm.vreeman.com/ns.html?id=GTM-WKSDWK" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<header>
<h1>Realtime Dashboard</h1>
<p><a href="https://vreeman.com/">Home</a> | <a href="https://vreeman.com/tools">Tools</a></p>
</header>
<div id="embed-api-auth-container"></div>
<div id="view-selector-container"></div>
<hr>
<div id="active-users-container"></div>
<div id="active-users-organic-container"></div>
<div id="active-users-social-container"></div>
<div id="pageviews-container"></div>
<div id="totalEvents-container"></div>
<hr>
<footer>
<p>Vreeman.com is the personal website of Simon Vreeman.</p>
<dl>
<dt>Privacy & Cookie Policy</dt>
<dd>Vreeman.com uses Google Analytics (<code>_ga</code>, <code>FPID</code>, & <code>FPLC</code>), and Google Tag Manager Server-side to measure and analyze anonymous user behavior data to improve the website in an ethical manner.</dd>
<dt>Colophon</dt>
<dd>Vreeman.com uses Cloudflare Pages to ensure it loads fast and the source code is hosted on Github.</dd>
<dt>Licenses</dt>
<dd>Text is licensed under <a href="https://creativecommons.org/licenses/by/4.0/" rel="license" title="Creative Commons Attribution 4.0 International License" data-vars-outbound-text="Creative Commons License" data-vars-outbound-link="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. <code></></code> is licensed under <a href="https://opensource.org/licenses/MIT" rel="license" title="MIT License" data-vars-outbound-text="MIT License" data-vars-outbound-link="https://opensource.org/licenses/MIT">MIT License</a>.</dd>
</dl>
</footer>
<script>
(function(w,d,s,g,js,fs){
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}};
js=d.createElement(s);fs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');};
}(window,document,'script'));
</script>
<script src="https://ga-dev-tools.appspot.com/public/javascript/embed-api/components/view-selector2.js"></script>
<script>
!function(t){function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";gapi.analytics.ready(function(){gapi.analytics.createComponent("ActiveUsers",{initialize:function(){this.activeUsers=0,gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},execute:function(){this.polling_&&this.stop(),this.render_(),gapi.analytics.auth.isAuthorized()?this.pollActiveUsers_():gapi.analytics.auth.once("signIn",this.pollActiveUsers_.bind(this))},stop:function(){clearTimeout(this.timeout_),this.polling_=!1,this.emit("stop",{activeUsers:this.activeUsers})},render_:function(){var t=this.get();this.container="string"==typeof t.container?document.getElementById(t.container):t.container,this.container.innerHTML=t.template||this.template,this.container.querySelector("b").innerHTML=this.activeUsers},pollActiveUsers_:function(){var t=this.get(),i=1e3*(t.pollingInterval||5);if(isNaN(i)||5e3>i)throw new Error("Frequency must be 5 seconds or more.");this.polling_=!0,gapi.client.analytics.data.realtime.get({ids:t.ids,metrics:"rt:activeUsers"}).then(function(t){var e=t.result,s=e.totalResults?+e.rows[0][0]:0,n=this.activeUsers;this.emit("success",{activeUsers:this.activeUsers}),s!=n&&(this.activeUsers=s,this.onChange_(s-n)),1==this.polling_&&(this.timeout_=setTimeout(this.pollActiveUsers_.bind(this),i))}.bind(this))},onChange_:function(t){var i=this.container.querySelector("b");i&&(i.innerHTML=this.activeUsers),this.emit("change",{activeUsers:this.activeUsers,delta:t}),t>0?this.emit("increase",{activeUsers:this.activeUsers,delta:t}):this.emit("decrease",{activeUsers:this.activeUsers,delta:t})},handleSignOut_:function(){this.stop(),gapi.analytics.auth.once("signIn",this.handleSignIn_.bind(this))},handleSignIn_:function(){this.pollActiveUsers_(),gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},template:'<div class="ActiveUsers">Active Users: <b class="ActiveUsers-value"></b></div>'})})}]);
</script>
<script>
!function(t){function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";gapi.analytics.ready(function(){gapi.analytics.createComponent("ActiveUsersOrganic",{initialize:function(){this.activeUsersOrganic=0,gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},execute:function(){this.polling_&&this.stop(),this.render_(),gapi.analytics.auth.isAuthorized()?this.pollActiveUsersOrganic_():gapi.analytics.auth.once("signIn",this.pollActiveUsersOrganic_.bind(this))},stop:function(){clearTimeout(this.timeout_),this.polling_=!1,this.emit("stop",{activeUsersOrganic:this.activeUsersOrganic})},render_:function(){var t=this.get();this.container="string"==typeof t.container?document.getElementById(t.container):t.container,this.container.innerHTML=t.template||this.template,this.container.querySelector("b").innerHTML=this.activeUsersOrganic},pollActiveUsersOrganic_:function(){var t=this.get(),i=1e3*(t.pollingInterval||5);if(isNaN(i)||5e3>i)throw new Error("Frequency must be 5 seconds or more.");this.polling_=!0,gapi.client.analytics.data.realtime.get({ids:t.ids,metrics:"rt:activeUsers",filters:"rt:trafficType==ORGANIC"}).then(function(t){var e=t.result,s=e.totalResults?+e.rows[0][0]:0,n=this.activeUsersOrganic;this.emit("success",{activeUsersOrganic:this.activeUsersOrganic}),s!=n&&(this.activeUsersOrganic=s,this.onChange_(s-n)),1==this.polling_&&(this.timeout_=setTimeout(this.pollActiveUsersOrganic_.bind(this),i))}.bind(this))},onChange_:function(t){var i=this.container.querySelector("b");i&&(i.innerHTML=this.activeUsersOrganic),this.emit("change",{activeUsersOrganic:this.activeUsersOrganic,delta:t}),t>0?this.emit("increase",{activeUsersOrganic:this.activeUsersOrganic,delta:t}):this.emit("decrease",{activeUsersOrganic:this.activeUsersOrganic,delta:t})},handleSignOut_:function(){this.stop(),gapi.analytics.auth.once("signIn",this.handleSignIn_.bind(this))},handleSignIn_:function(){this.pollActiveUsersOrganic_(),gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},template:'<div class="ActiveUsersOrganic">Organic Active Users: <b class="ActiveUsersOrganic-value"></b></div>'})})}]);
</script>
<script>
!function(t){function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";gapi.analytics.ready(function(){gapi.analytics.createComponent("ActiveUsersSocial",{initialize:function(){this.activeUsersSocial=0,gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},execute:function(){this.polling_&&this.stop(),this.render_(),gapi.analytics.auth.isAuthorized()?this.pollActiveUsersSocial_():gapi.analytics.auth.once("signIn",this.pollActiveUsersSocial_.bind(this))},stop:function(){clearTimeout(this.timeout_),this.polling_=!1,this.emit("stop",{activeUsersSocial:this.activeUsersSocial})},render_:function(){var t=this.get();this.container="string"==typeof t.container?document.getElementById(t.container):t.container,this.container.innerHTML=t.template||this.template,this.container.querySelector("b").innerHTML=this.activeUsersSocial},pollActiveUsersSocial_:function(){var t=this.get(),i=1e3*(t.pollingInterval||5);if(isNaN(i)||5e3>i)throw new Error("Frequency must be 5 seconds or more.");this.polling_=!0,gapi.client.analytics.data.realtime.get({ids:t.ids,metrics:"rt:activeUsers",filters:"rt:trafficType==SOCIAL"}).then(function(t){var e=t.result,s=e.totalResults?+e.rows[0][0]:0,n=this.activeUsersSocial;this.emit("success",{activeUsersSocial:this.activeUsersSocial}),s!=n&&(this.activeUsersSocial=s,this.onChange_(s-n)),1==this.polling_&&(this.timeout_=setTimeout(this.pollActiveUsersSocial_.bind(this),i))}.bind(this))},onChange_:function(t){var i=this.container.querySelector("b");i&&(i.innerHTML=this.activeUsersSocial),this.emit("change",{activeUsersSocial:this.activeUsersSocial,delta:t}),t>0?this.emit("increase",{activeUsersSocial:this.activeUsersSocial,delta:t}):this.emit("decrease",{activeUsersSocial:this.activeUsersSocial,delta:t})},handleSignOut_:function(){this.stop(),gapi.analytics.auth.once("signIn",this.handleSignIn_.bind(this))},handleSignIn_:function(){this.pollActiveUsersSocial_(),gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},template:'<div class="ActiveUsersSocial">Social Active Users: <b class="ActiveUsersSocial-value"></b></div>'})})}]);
</script>
<script>
!function(t){function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";gapi.analytics.ready(function(){gapi.analytics.createComponent("pageviews",{initialize:function(){this.pageviews=0,gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},execute:function(){this.polling_&&this.stop(),this.render_(),gapi.analytics.auth.isAuthorized()?this.pollpageviews_():gapi.analytics.auth.once("signIn",this.pollpageviews_.bind(this))},stop:function(){clearTimeout(this.timeout_),this.polling_=!1,this.emit("stop",{pageviews:this.pageviews})},render_:function(){var t=this.get();this.container="string"==typeof t.container?document.getElementById(t.container):t.container,this.container.innerHTML=t.template||this.template,this.container.querySelector("b").innerHTML=this.pageviews},pollpageviews_:function(){var t=this.get(),i=1e3*(t.pollingInterval||5);if(isNaN(i)||5e3>i)throw new Error("Frequency must be 5 seconds or more.");this.polling_=!0,gapi.client.analytics.data.realtime.get({ids:t.ids,metrics:"rt:pageviews"}).then(function(t){var e=t.result,s=e.totalResults?+e.rows[0][0]:0,n=this.pageviews;this.emit("success",{pageviews:this.pageviews}),s!=n&&(this.pageviews=s,this.onChange_(s-n)),1==this.polling_&&(this.timeout_=setTimeout(this.pollpageviews_.bind(this),i))}.bind(this))},onChange_:function(t){var i=this.container.querySelector("b");i&&(i.innerHTML=this.pageviews),this.emit("change",{pageviews:this.pageviews,delta:t}),t>0?this.emit("increase",{pageviews:this.pageviews,delta:t}):this.emit("decrease",{pageviews:this.pageviews,delta:t})},handleSignOut_:function(){this.stop(),gapi.analytics.auth.once("signIn",this.handleSignIn_.bind(this))},handleSignIn_:function(){this.pollpageviews_(),gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},template:'<div class="pageviews">Pageviews (Last 30 min): <b class="pageviews-value"></b></div>'})})}]);
</script>
<script>
!function(t){function i(s){if(e[s])return e[s].exports;var n=e[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i){"use strict";gapi.analytics.ready(function(){gapi.analytics.createComponent("totalEvents",{initialize:function(){this.totalEvents=0,gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},execute:function(){this.polling_&&this.stop(),this.render_(),gapi.analytics.auth.isAuthorized()?this.polltotalEvents_():gapi.analytics.auth.once("signIn",this.polltotalEvents_.bind(this))},stop:function(){clearTimeout(this.timeout_),this.polling_=!1,this.emit("stop",{totalEvents:this.totalEvents})},render_:function(){var t=this.get();this.container="string"==typeof t.container?document.getElementById(t.container):t.container,this.container.innerHTML=t.template||this.template,this.container.querySelector("b").innerHTML=this.totalEvents},polltotalEvents_:function(){var t=this.get(),i=1e3*(t.pollingInterval||5);if(isNaN(i)||5e3>i)throw new Error("Frequency must be 5 seconds or more.");this.polling_=!0,gapi.client.analytics.data.realtime.get({ids:t.ids,metrics:"rt:totalEvents"}).then(function(t){var e=t.result,s=e.totalResults?+e.rows[0][0]:0,n=this.totalEvents;this.emit("success",{totalEvents:this.totalEvents}),s!=n&&(this.totalEvents=s,this.onChange_(s-n)),1==this.polling_&&(this.timeout_=setTimeout(this.polltotalEvents_.bind(this),i))}.bind(this))},onChange_:function(t){var i=this.container.querySelector("b");i&&(i.innerHTML=this.totalEvents),this.emit("change",{totalEvents:this.totalEvents,delta:t}),t>0?this.emit("increase",{totalEvents:this.totalEvents,delta:t}):this.emit("decrease",{totalEvents:this.totalEvents,delta:t})},handleSignOut_:function(){this.stop(),gapi.analytics.auth.once("signIn",this.handleSignIn_.bind(this))},handleSignIn_:function(){this.polltotalEvents_(),gapi.analytics.auth.once("signOut",this.handleSignOut_.bind(this))},template:'<div class="totalEvents">Total Events (Last 30 min): <b class="totalEvents-value"></b></div>'})})}]);
</script>
<script>
gapi.analytics.ready(function() {
gapi.analytics.auth.authorize({
container: 'embed-api-auth-container',
clientid: '25048035464-k0o4mek6tcc3ii3f1jmvbcajb26igbkn.apps.googleusercontent.com'
});
var activeUsers = new gapi.analytics.ext.ActiveUsers({
container: 'active-users-container',
pollingInterval: 5
});
var activeUsersOrganic = new gapi.analytics.ext.ActiveUsersOrganic({
container: 'active-users-organic-container',
pollingInterval: 5
});
var activeUsersSocial = new gapi.analytics.ext.ActiveUsersSocial({
container: 'active-users-social-container',
pollingInterval: 5
});
var pageviews = new gapi.analytics.ext.pageviews({
container: 'pageviews-container',
pollingInterval: 5
});
var totalEvents = new gapi.analytics.ext.totalEvents({
container: 'totalEvents-container',
pollingInterval: 5
});
activeUsers.once('success', function() {
var element = this.container.firstChild;
var timeout;
this.on('change', function(data) {
var element = this.container.firstChild;
var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
element.className += (' ' + animationClass);
clearTimeout(timeout);
timeout = setTimeout(function() {
element.className =
element.className.replace(/ is-(increasing|decreasing)/g, '');
}, 3000);
});
});
activeUsersOrganic.once('success', function() {
var element = this.container.firstChild;
var timeout;
this.on('change', function(data) {
var element = this.container.firstChild;
var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
element.className += (' ' + animationClass);
clearTimeout(timeout);
timeout = setTimeout(function() {
element.className =
element.className.replace(/ is-(increasing|decreasing)/g, '');
}, 3000);
});
});
activeUsersSocial.once('success', function() {
var element = this.container.firstChild;
var timeout;
this.on('change', function(data) {
var element = this.container.firstChild;
var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
element.className += (' ' + animationClass);
clearTimeout(timeout);
timeout = setTimeout(function() {
element.className =
element.className.replace(/ is-(increasing|decreasing)/g, '');
}, 3000);
});
});
pageviews.once('success', function() {
var element = this.container.firstChild;
var timeout;
this.on('change', function(data) {
var element = this.container.firstChild;
var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
element.className += (' ' + animationClass);
clearTimeout(timeout);
timeout = setTimeout(function() {
element.className =
element.className.replace(/ is-(increasing|decreasing)/g, '');
}, 3000);
});
});
totalEvents.once('success', function() {
var element = this.container.firstChild;
var timeout;
this.on('change', function(data) {
var element = this.container.firstChild;
var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
element.className += (' ' + animationClass);
clearTimeout(timeout);
timeout = setTimeout(function() {
element.className =
element.className.replace(/ is-(increasing|decreasing)/g, '');
}, 3000);
});
});
var viewSelector = new gapi.analytics.ext.ViewSelector2({
container: 'view-selector-container',
})
.execute();
viewSelector.on('viewChange', function(data) {
var title = document.getElementById('view-name');
activeUsers.set(data).execute();
activeUsersOrganic.set(data).execute();
activeUsersSocial.set(data).execute();
pageviews.set(data).execute();
totalEvents.set(data).execute();
});
});
</script>
</body>
</html>