Skip to content

Commit 7c32a0b

Browse files
committed
Add Google Analytics code
1 parent ca42b9c commit 7c32a0b

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

app/config/production.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@
2727
],
2828
],
2929
],
30+
'site' => [
31+
'analytics' => [
32+
'google' => [
33+
'code' => 'G-JLM4TB5D6Y',
34+
'enabled' => true,
35+
],
36+
],
37+
],
3038
];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if site.analytics.google.code and site.analytics.google.enabled %}
2+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.code }}"></script>
3+
<script>
4+
window.dataLayer = window.dataLayer || [];
5+
function gtag(){dataLayer.push(arguments);}
6+
gtag('js', new Date());
7+
8+
gtag('config', '{{ site.analytics.google.code }}');
9+
</script>
10+
{% elseif site.debug.info %}
11+
<script>
12+
console.log("Google Analytics is disabled or code has not been set.");
13+
</script>
14+
{% endif %}

0 commit comments

Comments
 (0)