Upgrade GA tag (analytics.js) to the latest tag (gtag.js)

This commit is contained in:
Cotes Chung 2020-10-12 05:27:13 +08:00
parent db5a58638d
commit 3c2675c4a1
3 changed files with 13 additions and 13 deletions

View file

@ -5,12 +5,12 @@
© 2017-2019 Cotes Chung
MIT License
-->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics.id }}"></script>
<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),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
ga('create', '{{ site.google_analytics.id }}', 'auto');
ga('send', 'pageview');
gtag('js', new Date());
gtag('config', '{{ site.google_analytics.id }}');
</script>

View file

@ -35,7 +35,11 @@
{% endif %}
<!-- PWA -->
{% if jekyll.environment == 'production' %}
{% include google-analytics.html %}
<!-- PWA -->
<script src="{{ '/app.js' | relative_url }}" defer></script>
{% endif %}

View file

@ -52,10 +52,6 @@ layout: compress
<i class="fas fa-angle-up"></i>
</a>
{% if jekyll.environment == 'production' %}
{% include google-analytics.html %}
{% endif %}
{% include search-loader.html %}
</body>