Add support for Google Analytics with global site tag (gtag.js) (#1563)

For documentation see https://developers.google.com/analytics/devguides/collection/gtagjs/
and https://support.google.com/analytics/answer/7538414.
This commit is contained in:
Matías E. Fernández
2018-03-13 00:27:42 +01:00
committed by Michael Rose
parent 39bf00055a
commit 79d0b75683
4 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.analytics.google.tracking_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.analytics.google.tracking_id }}');
</script>

View File

@ -5,6 +5,8 @@
{% include /analytics-providers/google.html %}
{% when "google-universal" %}
{% include /analytics-providers/google-universal.html %}
{% when "google-gtag" %}
{% include /analytics-providers/google-gtag.html %}
{% when "custom" %}
{% include /analytics-providers/custom.html %}
{% endcase %}