
{% if site.owner.google.analytics %}
<!-- Manual Analytics Snippet -->
<!-- https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters-->
<script>
function sendData() {
    var ls = [];
    var tid = '{{ site.owner.google.analytics }}';  //Analytics ID
    var cid = Math.floor(100+Math.random()*900);
    var fields = ['v', 'tid', 'cid', 't', 'aip', 'uip', 'dl', 'dt'];  //
    var values = [1, tid, cid, 'pageview', 1, '0.0.0.0', window.location.href, document.title]; //
    for (var i = 0; i<fields.length; i++) {
        ls.push(String(fields[i]) + '=' + encodeURIComponent(String(values[i])));
    }
    var data = ls.join('&');
    var request = new XMLHttpRequest();
    request.open("POST", "https://www.google-analytics.com/collect", true);
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    request.send(data);
}
sendData();
</script>

{% endif %}


{% if page.comments %}
  {% include _disqus_comments.html %}
{% endif %}


{% if site.owner.google.analytics %}
<!-- Manual Analytics Snippet -->
<!-- https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters-->
<script>

let ls = [];
const tid = '{{ site.owner.google.analytics }}';  //Your Analytics ID
const cid = Math.floor(100+Math.random()*900);
const fields = ['v', 'tid', 'cid', 't', 'aip', 'uip', 'dl', 'dt']; 
const values = [1, tid, cid, 'pageview', 1, '0.0.0.0', window.location.href, document.title]; 
for (var i = 0; i<fields.length; i++) {
  ls.push(String(fields[i]) + '=' + encodeURIComponent(String(values[i])));
}
const data = ls.join('&');
const request = {
  method: 'POST',
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  body: data
};
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('https://www.google-analytics.com/collect', request);

</script>

{% endif %}


{% if page.comments %}
  {% include _disqus_comments.html %}
{% endif %}

Use fetch in analytics snippet
Use fetch in analytics snippet
