Add GoatCounter to a SPA

Custom count() example for hooking in to an SPA nagivating by #:

<script>
    window.goatcounter = {no_onload: true}

    window.addEventListener('hashchange', function(e) {
        window.goatcounter.count({
            path: location.pathname + location.search + location.hash,
        })
    })
</script>
<script data-goatcounter="https://stats.196000.xyz/count"
        async src="//stats.196000.xyz/count.js"></script>

Questions or problems?

Feel free to get in touch if you’ve got any questions or having any problems; a lot of times they can be resolved without too much problems.

Ways to contact me: show