Skip to content

Commit dfc3ce3

Browse files
authored
Merge pull request #1183 from sonnyarora/add-google-analytics-4
Add Google Analytics 4 Support (Issue #1152)
2 parents aa9ed61 + 96d1b6e commit dfc3ce3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

_config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ social:
7373

7474
# Analytics
7575
analytics:
76-
provider : "google-universal" # false (default), "google", "google-universal", "custom"
76+
provider : "google-universal" # false (default), "google", "google-universal", "google-analytics-4", "custom"
7777
google:
7878
tracking_id :
7979

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script async src="https://www.googletagmanager.com/gtag/js?id={{site.analytics.google.tracking_id}}"></script>
2+
<script>
3+
window.dataLayer = window.dataLayer || [];
4+
function gtag(){dataLayer.push(arguments);}
5+
gtag('js', new Date());
6+
7+
gtag('config', '{{site.analytics.google.tracking_id}}');
8+
</script>

_includes/analytics.html

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
{% include /analytics-providers/google.html %}
66
{% when "google-universal" %}
77
{% include /analytics-providers/google-universal.html %}
8+
{% when "google-analytics-4" %}
9+
{% include /analytics-providers/google-analytics-4.html %}
810
{% when "custom" %}
911
{% include /analytics-providers/custom.html %}
1012
{% endcase %}

0 commit comments

Comments
 (0)