Skip to content

Commit

Permalink
Move GA script to head.html (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
zt-chen committed Nov 30, 2020
1 parent 4a866f6 commit 2781e2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 12 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@
{% if site.enable_darkmode %}
<script src="{{ '/assets/js/theme.js' | relative_url }}"></script>
{% endif %}

{% if site.enable_google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', '{{ site.google_analytics }}');
</script>
{% endif %}
11 changes: 0 additions & 11 deletions _includes/scripts/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
</script>
{% endif %}

{% if site.enable_google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', '{{ site.google_analytics }}');
</script>
{% endif %}

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

0 comments on commit 2781e2e

Please sign in to comment.