Google analytics update (#31)

* Update Google Analytics tracking code

Previous template was using ga.js which is considered legacy now. The
recommended way to enable Google Analytics now is via gtag.js:
https://support.google.com/analytics/answer/1008080

* Do not store IP address (personally identifyable information)

With GDPR in effect IP addresses are considered personally identifyable
information, and storing them becomes legally complicated. Anonymizing IPs
seems to be a sensible default behavior.

The only drawback is slightly reduced geolocation accuracy.

More information:
- https://developers.google.com/analytics/devguides/collection/gtagjs/ip-anonymization
- https://support.google.com/analytics/answer/2763052
- https://www.blastam.com/blog/5-actionable-steps-gdpr-compliance-google-analytics
This commit is contained in:
Vitaly Potyarkin 2018-06-29 08:15:14 +03:00 committed by Arul
parent 1e0a56e0d8
commit e6ccaf33d2

View file

@ -1,13 +1,11 @@
{% if GOOGLE_ANALYTICS %} {% if GOOGLE_ANALYTICS %}
<script type="text/javascript"> <!-- Global Site Tag (gtag.js) - Google Analytics -->
var _gaq = _gaq || []; <script async src="https://www.googletagmanager.com/gtag/js?id={{GOOGLE_ANALYTICS}}"></script>
_gaq.push(['_setAccount', '{{GOOGLE_ANALYTICS}}']); <script>
_gaq.push(['_trackPageview']); window.dataLayer = window.dataLayer || [];
(function() { function gtag(){dataLayer.push(arguments);}
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; gtag('js', new Date());
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; gtag('config', '{{GOOGLE_ANALYTICS}}', { 'anonymize_ip': true });
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script> </script>
{% endif %} {% endif %}
{% if GAUGES %} {% if GAUGES %}