Skip to content

Commit 3a7ab3d

Browse files
authored
Update Google Analytics and correct mistyped var (Phlow#244)
Updated old Google Analytics (analytics.js) to new Global site tag (gtag.js) Google Analytics. BTW old Google Analytics was not working here because of mistyped variable.
1 parent 74f7cf6 commit 3a7ab3d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

_includes/_head.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@
9090
{% endunless %}
9191

9292
{% if site.google_analytics_tracking_id %}
93+
<!-- Global site tag (gtag.js) - Google Analytics -->
94+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_tracking_id }}"></script>
9395
<script>
94-
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
95-
ga('create', '{{ site.analytics.google.tracking_id }}', 'auto');
96-
ga('send', 'pageview');
96+
window.dataLayer = window.dataLayer || [];
97+
function gtag(){dataLayer.push(arguments);}
98+
gtag('js', new Date());
99+
100+
gtag('config', '{{ site.google_analytics_tracking_id }}');
97101
</script>
98-
<script async src='https://www.google-analytics.com/analytics.js'></script>
99102
{% endif %}
100103

0 commit comments

Comments
 (0)