Skip to content

Commit

Permalink
re-enabling goatcounter
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonfigueroa committed Oct 8, 2024
1 parent ea65c6f commit 9cfbb9b
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@

<!-- goatcounter JS -->

{{/* <script>
<script>
// GoatCounter: https://www.goatcounter.com
// This file is released under the ISC license: https://opensource.org/licenses/ISC
;(function() {
Expand Down Expand Up @@ -313,7 +313,24 @@
var url = goatcounter.url(vars)
if (!url)
return warn('not counting because path callback returned null')
navigator.sendBeacon(url)

if (!navigator.sendBeacon(url)) {
// This mostly fails due to being blocked by CSP; try again with an
// image-based fallback.
var img = document.createElement('img')
img.src = url
img.style.position = 'absolute' // Affect layout less.
img.style.bottom = '0px'
img.style.width = '1px'
img.style.height = '1px'
img.loading = 'eager'
img.setAttribute('alt', '')
img.setAttribute('aria-hidden', 'true')

var rm = function() { if (img && img.parentNode) img.parentNode.removeChild(img) }
img.addEventListener('load', rm, false)
document.body.appendChild(img)
}
}

// Get a query parameter.
Expand Down Expand Up @@ -418,4 +435,4 @@
goatcounter.bind_events()
})
})();
</script> */}}
</script>

0 comments on commit 9cfbb9b

Please sign in to comment.