1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-11 23:55:16 +01:00

GA tweaks for dev

This commit is contained in:
Matthias Kretschmann 2015-11-20 23:36:45 +01:00
parent d5615b96bf
commit 3a5fde7e0c

View File

@ -19,26 +19,39 @@
<script> <script>
(function(window) { (function(window) {
// Google Analytics async snippet // Google Analytics async snippet
// http://goo.gl/3FPNDx // http://goo.gl/3FPNDx
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)}; window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};
ga.l=+new Date; ga.l=+new Date;
// Create the GA tracker // Create the GA tracker
ga('create', 'UA-1441794-2', 'auto', {siteSpeedSampleRate: 10}); ga('create', 'UA-1441794-2', 'auto', {siteSpeedSampleRate: 10});
// Send initial pageview {% if jekyll.environment != 'production' %}
ga('send', 'pageview'); // In non-production mode, simply log GA hits to the console.
// Note, tasks must be set before sending the first hit
ga(function(tracker) {
tracker.set('sendHitTask', function() {
// Throw to stop subsequent tasks.
throw 'Abort tracking in non-production environments.'
});
});
{% endif %}
// Track uncaught errors // Send initial pageview
window.onerror = function(message, url, line, col) { ga('send', 'pageview');
var desc = message + ' (line: ' + line + ', url: ' + url + ', col: '
// Track uncaught errors
window.onerror = function(message, url, line, col) {
var desc = message + ' (line: ' + line + ', url: ' + url + ', col: '
+ col + ')'; + col + ')';
ga('send', 'exception', {
exDescription: 'window.onerror: ' + desc, ga('send', 'exception', {
exFatal: false exDescription: 'window.onerror: ' + desc,
}); exFatal: false
}; });
};
}(window)); }(window));
</script> </script>