<!-- Google tag (gtag.js) -->
<script>
  function initGoogleAnalytics() {
    var doNotTrack = (window.doNotTrack === "1" || navigator.doNotTrack === "1" ||
      navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1");
    var enableDNT = "{{ site.enableDNT | default: true }}" == "true";

    if (!enableDNT || !doNotTrack) {
      var measurementId = '{{ site.google_analytics }}';

      (function(src) {
        var tag = document.createElement('script');
        tag.src = src;
        tag.async = true;
        var firstScriptTag = document.getElementsByTagName('script')[0];
        firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      })('https://www.googletagmanager.com/gtag/js?id=' + measurementId);

      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', measurementId);
    }
  }
  window.addEventListener("load", initGoogleAnalytics);
</script>

