Replace old analytics.js with gtag.js

This commit is contained in:
Johan Guldmyr 2023-04-17 10:59:43 +03:00
commit 26937d659f
No known key found for this signature in database
GPG key ID: B856C95D74525E1C

View file

@ -1,31 +1,13 @@
{% if GOOGLE_ANALYTICS %}
<script>
(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);
a.async = 1;
a.src = g;
m = s.getElementsByTagName(o)[0];
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', '{{ GOOGLE_ANALYTICS }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
{%- if GOOGLE_ANALYTICS_GTAG %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLE_ANALYTICS_GTAG }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ GOOGLE_ANALYTICS }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ GOOGLE_ANALYTICS_GTAG }}');
gtag('config', '{{ GOOGLE_ANALYTICS }}');
</script>
{%- endif %}
{% endif %}
{% if GAUGES %}
<script>