Add Google Analytics in production
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Javascript Spaghetti Profiler</title>
|
||||
<title>Yellow Lab Tools - Awaiting</title>
|
||||
<link rel="stylesheet" type="text/css" href="/public/styles/main.css">
|
||||
<link rel="stylesheet" type="text/css" href="/public/styles/launchTest.css">
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
@@ -32,6 +32,7 @@
|
||||
} else {
|
||||
statusElement.innerHTML = 'Waiting behind ' + (position) + ' other tests';
|
||||
}
|
||||
sendPositionInQueueToGA(position);
|
||||
});
|
||||
|
||||
socket.on('complete', function() {
|
||||
@@ -49,6 +50,28 @@
|
||||
});
|
||||
|
||||
askStatus();
|
||||
|
||||
|
||||
var GA_ID = '%%GA_ID%%';
|
||||
if (GA_ID.length > 0 && window.location.host === 'yellowlab.tools') {
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', GA_ID, 'auto');
|
||||
}
|
||||
|
||||
// Need stats on average queue position
|
||||
var positionAlreadySent = false;
|
||||
function sendPositionInQueueToGA(position) {
|
||||
if (!positionAlreadySent && GA_ID.length > 0 && window.location.host === 'yellowlab.tools') {
|
||||
ga('send', 'pageview', {
|
||||
queuePosition: position
|
||||
});
|
||||
positionAlreadySent = true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user