Skip to content

Commit 2781e2e

Browse files
authored
Move GA script to head.html (alshedivat#140)
1 parent 4a866f6 commit 2781e2e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

_includes/head.html

+12
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@
3737
{% if site.enable_darkmode %}
3838
<script src="{{ '/assets/js/theme.js' | relative_url }}"></script>
3939
{% endif %}
40+
41+
{% if site.enable_google_analytics %}
42+
<!-- Global site tag (gtag.js) - Google Analytics -->
43+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
44+
<script>
45+
window.dataLayer = window.dataLayer || [];
46+
function gtag() { dataLayer.push(arguments); }
47+
gtag('js', new Date());
48+
49+
gtag('config', '{{ site.google_analytics }}');
50+
</script>
51+
{% endif %}

_includes/scripts/misc.html

-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55
</script>
66
{% endif %}
77

8-
{% if site.enable_google_analytics %}
9-
<!-- Global site tag (gtag.js) - Google Analytics -->
10-
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
11-
<script>
12-
window.dataLayer = window.dataLayer || [];
13-
function gtag() { dataLayer.push(arguments); }
14-
gtag('js', new Date());
15-
16-
gtag('config', '{{ site.google_analytics }}');
17-
</script>
18-
{% endif %}
198

209
<!-- Load Common JS -->
2110
<script src="{{ '/assets/js/common.js' | relative_url }}"></script>

0 commit comments

Comments
 (0)