aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-01-22 13:10:14 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2022-01-22 13:10:14 +0300
commitba619d5a98dcb86605f850211ab6289d75443416 (patch)
tree5718b1e8a8dad74376e93975c92654ada7319a61
parentREADME: update (diff)
downloadjekyll-theme-ba619d5a98dcb86605f850211ab6289d75443416.tar.gz
jekyll-theme-ba619d5a98dcb86605f850211ab6289d75443416.zip
support Google Analytics
-rw-r--r--README.md2
-rw-r--r--_config.yml1
-rw-r--r--_includes/common/ga.html9
-rw-r--r--_includes/common/header.html4
4 files changed, 16 insertions, 0 deletions
diff --git a/README.md b/README.md
index ac7be4a..483a9ac 100644
--- a/README.md
+++ b/README.md
@@ -58,6 +58,8 @@ settings:
github:
link: GitHub
icon: globe
+ # If you want to enable Google Analytics, optional:
+ ga_tag: X-XXXXXXXXXX
```
Features
diff --git a/_config.yml b/_config.yml
index 5542d59..ffd8e21 100644
--- a/_config.yml
+++ b/_config.yml
@@ -48,3 +48,4 @@ settings:
# address of the owner.
name: Egor Tensin
email: Egor.Tensin@gmail.com
+ ga_tag: G-NEVP4S1FMV
diff --git a/_includes/common/ga.html b/_includes/common/ga.html
new file mode 100644
index 0000000..56eaca7
--- /dev/null
+++ b/_includes/common/ga.html
@@ -0,0 +1,9 @@
+<!-- Global site tag (gtag.js) - Google Analytics -->
+<script async src="https://www.googletagmanager.com/gtag/js?id={{ include.ga_tag }}"></script>
+<script>
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
+
+ gtag('config', '{{ include.ga_tag }}');
+</script>
diff --git a/_includes/common/header.html b/_includes/common/header.html
index a41b26e..8546fb5 100644
--- a/_includes/common/header.html
+++ b/_includes/common/header.html
@@ -58,6 +58,10 @@
<link rel="stylesheet" href="{{ url }}">
{% endfor %}
{% endif %}
+
+ {% if site.settings.ga_tag %}
+ {% include common/ga.html ga_tag=site.settings.ga_tag %}
+ {% endif %}
</head>
<body>
<div class="top-level-footer-wrapper">