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 © 2017-2019 Cotes Chung
MIT License 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> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ window.dataLayer = window.dataLayer || [];
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), function gtag(){dataLayer.push(arguments);}
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'); gtag('js', new Date());
gtag('config', '{{ site.google_analytics.id }}');
ga('create', '{{ site.google_analytics.id }}', 'auto');
ga('send', 'pageview');
</script> </script>

View file

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

View file

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