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

@ -27,6 +27,17 @@
// Create the GA tracker
ga('create', 'UA-1441794-2', 'auto', {siteSpeedSampleRate: 10});
{% if jekyll.environment != 'production' %}
// 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 %}
// Send initial pageview
ga('send', 'pageview');
@ -34,11 +45,13 @@
window.onerror = function(message, url, line, col) {
var desc = message + ' (line: ' + line + ', url: ' + url + ', col: '
+ col + ')';
ga('send', 'exception', {
exDescription: 'window.onerror: ' + desc,
exFatal: false
});
};
}(window));
</script>