Skip to content

Commit a1f2699

Browse files
committed
Upgrade GA tag (analytics.js) to the latest tag (gtag.js)
1 parent 2d1b77a commit a1f2699

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

_includes/google-analytics.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
© 2017-2019 Cotes Chung
66
MIT License
77
-->
8+
<!-- Global site tag (gtag.js) - Google Analytics -->
9+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics.id }}"></script>
810
<script>
9-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
10-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
11-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
12-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
13-
14-
ga('create', '{{ site.google_analytics.id }}', 'auto');
15-
ga('send', 'pageview');
11+
window.dataLayer = window.dataLayer || [];
12+
function gtag(){dataLayer.push(arguments);}
13+
14+
gtag('js', new Date());
15+
gtag('config', '{{ site.google_analytics.id }}');
1616
</script>

_includes/js-selector.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
{% endif %}
3636

3737

38-
<!-- PWA -->
3938
{% if jekyll.environment == 'production' %}
39+
40+
{% include google-analytics.html %}
41+
42+
<!-- PWA -->
4043
<script src="{{ '/app.js' | relative_url }}" defer></script>
44+
4145
{% endif %}

_layouts/default.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@
5252
<i class="fas fa-angle-up"></i>
5353
</a>
5454

55-
{% if jekyll.environment == 'production' %}
56-
{% include google-analytics.html %}
57-
{% endif %}
58-
5955
{% include search-loader.html %}
6056

6157
</body>
6258

63-
</html>
59+
</html>

0 commit comments

Comments
 (0)