diff options
author | Karl Hallsby <karl@hallsby.com> | 2021-06-18 23:02:21 -0500 |
---|---|---|
committer | Karl Hallsby <karl@hallsby.com> | 2021-06-18 23:02:21 -0500 |
commit | 3d6b437ebfb1c8c5e8f1beec215fb9e824adfad9 (patch) | |
tree | efa54734609075eaeff9d652b0b7404d4839b363 | |
parent | 7bf1363025ee6a042c7916abe90bf7dc36b3561a (diff) |
Add google analytics to siteadd-google-analytics
-rw-r--r-- | _config.yml | 1 | ||||
-rw-r--r-- | _includes/head/custom.html | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/_config.yml b/_config.yml index 58c9466..9948ef4 100644 --- a/_config.yml +++ b/_config.yml @@ -29,6 +29,7 @@ description: >- # this means to ignore newlines until "baseurl:" baseurl: "/" # the subpath of your site, e.g. /blog url: "https://karl.hallsby.com" # the base hostname & protocol for your site, e.g. http://example.com +google_analytics: G-1EB0J5LDCB author: type: "person" diff --git a/_includes/head/custom.html b/_includes/head/custom.html index 33b1508..def324f 100644 --- a/_includes/head/custom.html +++ b/_includes/head/custom.html @@ -1,3 +1,14 @@ <!-- start custom head snippets --> +{% if site.google_analytics and jekyll.environment == 'production' %} + <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 -%} + <!-- end custom head snippets --> |