mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
honor Do Not Track when setting up google analytics
This commit is contained in:
parent
ff7bba4dad
commit
4b75b96cb5
@ -17,29 +17,31 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function(window) {
|
(function(window, dnt) {
|
||||||
|
|
||||||
// Google Analytics async snippet
|
if (dnt !== "yes" && dnt !== "1") {
|
||||||
// http://goo.gl/3FPNDx
|
// Google Analytics async snippet
|
||||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};
|
// http://goo.gl/3FPNDx
|
||||||
ga.l=+new Date;
|
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};
|
||||||
|
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});
|
||||||
|
|
||||||
{% if jekyll.environment != 'production' %}
|
{% if jekyll.environment != 'production' %}
|
||||||
// In non-production mode, simply log GA hits to the console.
|
// In non-production mode, simply log GA hits to the console.
|
||||||
// Note, tasks must be set before sending the first hit
|
// Note, tasks must be set before sending the first hit
|
||||||
ga(function(tracker) {
|
ga(function(tracker) {
|
||||||
tracker.set('sendHitTask', function() {
|
tracker.set('sendHitTask', function() {
|
||||||
// Throw to stop subsequent tasks.
|
// Throw to stop subsequent tasks.
|
||||||
throw 'Abort tracking in non-production environments.'
|
throw 'Abort tracking in non-production environments.'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
// Send initial pageview
|
// Send initial pageview
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
|
}
|
||||||
|
|
||||||
// Track uncaught errors
|
// Track uncaught errors
|
||||||
window.onerror = function(message, url, line, col) {
|
window.onerror = function(message, url, line, col) {
|
||||||
@ -52,7 +54,7 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}(window));
|
}(window, navigator.doNotTrack || navigator.msDoNotTrack || null));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% if jekyll.environment == "production" %}
|
{% if jekyll.environment == "production" %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user