update ga

pull/1/head
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,30 +1,28 @@
{% 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>
<script>
window.dataLayer = window.dataLayer || [];
{% if gid %} function gtag() {
<script async src="https://www.googletagmanager.com/gtag/js?id={{ gid }}"></script> dataLayer.push(arguments);
<script> }
window.dataLayer = window.dataLayer || []; gtag('js', new Date());
gtag('config', '{{ $gid }}');
</script>
{% else %}
{% if site.google_analytics_id %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { function gtag() {
dataLayer.push(arguments); dataLayer.push(arguments);
} }
gtag('js', new Date()); gtag('js', new Date());
gtag('config', '{{ $gid }}'); gtag('config', '{{ site.google_analytics_id }}');
</script> </script>
{% else %} {% endif %}
{% if site.google_analytics_id %} {% endif %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics_id }}');
</script>
{% endif %}
{% endif %}
{% endif %} {% endif %}