Move GA script to head.html (#140)

This commit is contained in:
zt-chen 2020-11-30 15:00:47 +00:00 committed by GitHub
parent 4a866f64c4
commit 2781e2eb4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -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 %}

View File

@ -5,17 +5,6 @@ $(function () {$('[data-toggle="tooltip"]').tooltip()})
</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>