update ga

This commit is contained in:
Robert Austin 2019-03-13 17:46:17 +10:00
parent 4f35c2e653
commit 593d6e5fba
1 changed files with 24 additions and 26 deletions

View File

@ -1,10 +1,8 @@
{% if jekyll.environment == "production" %} {% if jekyll.environment == "production" %}
{% assign gid = site.env.NETLIFY_GOOGLE_ANALYTICS_ID %} {% assign gid = site.env.NETLIFY_GOOGLE_ANALYTICS_ID %}
{{ gid }} {% if gid %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ gid }}"></script>
{% if gid %} <script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ gid }}"></script>
<script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag() { function gtag() {
@ -12,11 +10,11 @@
} }
gtag('js', new Date()); gtag('js', new Date());
gtag('config', '{{ $gid }}'); gtag('config', '{{ $gid }}');
</script> </script>
{% else %} {% else %}
{% if site.google_analytics_id %} {% if site.google_analytics_id %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script> <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script>
<script> <script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag() { function gtag() {
@ -24,7 +22,7 @@
} }
gtag('js', new Date()); gtag('js', new Date());
gtag('config', '{{ site.google_analytics_id }}'); gtag('config', '{{ site.google_analytics_id }}');
</script> </script>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}