summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_config.yml1
-rw-r--r--_includes/head/custom.html11
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 -->