Skip to content

Commit

Permalink
Upgrade GA tag (analytics.js) to the latest tag (gtag.js)
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Oct 11, 2020
1 parent 2d1b77a commit a1f2699
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions _includes/google-analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -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');

ga('create', '{{ site.google_analytics.id }}', 'auto');
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());
gtag('config', '{{ site.google_analytics.id }}');
</script>
6 changes: 5 additions & 1 deletion _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
{% endif %}


<!-- PWA -->
{% if jekyll.environment == 'production' %}

{% include google-analytics.html %}

<!-- PWA -->
<script src="{{ '/app.js' | relative_url }}" defer></script>

{% endif %}
6 changes: 1 addition & 5 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@
<i class="fas fa-angle-up"></i>
</a>

{% if jekyll.environment == 'production' %}
{% include google-analytics.html %}
{% endif %}

{% include search-loader.html %}

</body>

</html>
</html>

0 comments on commit a1f2699

Please sign in to comment.