Skip to content

Commit 79d0b75

Browse files
matiasfrndzmmistakes
authored andcommittedMar 12, 2018
Add support for Google Analytics with global site tag (gtag.js) (mmistakes#1563)
For documentation see https://developers.google.com/analytics/devguides/collection/gtagjs/ and https://support.google.com/analytics/answer/7538414.
1 parent 39bf000 commit 79d0b75

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed
 

‎_config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ social:
8383

8484
# Analytics
8585
analytics:
86-
provider : false # false (default), "google", "google-universal", "custom"
86+
provider : false # false (default), "google", "google-universal", "google-gtag", "custom"
8787
google:
8888
tracking_id :
8989

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- Global site tag (gtag.js) - Google Analytics -->
2+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.tracking_id }}"></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.tracking_id }}');
9+
</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-gtag" %}
9+
{% include /analytics-providers/google-gtag.html %}
810
{% when "custom" %}
911
{% include /analytics-providers/custom.html %}
1012
{% endcase %}

‎docs/_docs/05-configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,14 @@ Analytics is disabled by default. To enable globally select one of the following
679679
| -------------------- | --------------------------------------------------------------- |
680680
| **google** | [Google Standard Analytics](https://www.google.com/analytics/) |
681681
| **google-universal** | [Google Universal Analytics](https://www.google.com/analytics/) |
682+
| **google-gtag** | [Google Analytics Global Site Tag)](https://www.google.com/analytics/) |
682683
| **custom** | Other analytics providers |
683684

684685
For Google Analytics add your Tracking Code:
685686

686687
```yaml
687688
analytics:
688-
provider: "google-universal"
689+
provider: "google-gtag"
689690
google:
690691
tracking_id: "UA-1234567-8"
691692
```

0 commit comments

Comments
 (0)
Please sign in to comment.