Skip to content

Commit

Permalink
Replace old analytics.js with gtag.js
Browse files Browse the repository at this point in the history
  • Loading branch information
martbhell committed Apr 17, 2023
1 parent 94e078c commit bd530f1
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions alchemy/templates/include/analytics.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
{% 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 %}

Expand Down

0 comments on commit bd530f1

Please sign in to comment.