Add gtag support for Google Analytics (#374)

This commit is contained in:
Harry Khanna 2018-07-06 11:31:25 -04:00 committed by Dean Attali
parent 362462948f
commit dfa273c1a4
3 changed files with 15 additions and 0 deletions

View File

@ -103,6 +103,9 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll"
# --- Web Statistics Section --- #
# Fill in your Google Analytics gtag.js ID to track your website using gtag
#gtag: ""
# Fill in your Google Analytics ID to track your website using GA
#google_analytics: ""

11
_includes/gtag.html Normal file
View File

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

View File

@ -13,6 +13,7 @@
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ site.baseurl }}/feed.xml" />
{% include gtag.html %}
{% include gtm_head.html %}
{% if layout.common-ext-css %}