Prevent tracking specific paths

Nothing will be automatically sent if window.goatcounter.no_onload is set; the easiest way to set this is from data-goatcounter-settings on the script tag:

<script data-goatcounter="https://stats.196000.xyz/count"
        data-goatcounter-settings='{"no_onload": true}'
        async src="//zgo.at/count.js"></script>

For static or server-side rendered sites this is usually the simplest approach.


You can also set this in JavaScript (before the script loads); for example to automatically skip if the <body>’s class contains goatcounter-skip:

<script>
    window.goatcounter = {
        no_onload: body.classList.contains('goatcounter-skip'),
    }
</script>
<script data-goatcounter="https://stats.196000.xyz/count"
        async src="//stats.196000.xyz/count.js"></script>

Or match against a list of paths:

<script>
    ['/wp-admin.php', '^/feed/.*'].forEach((p) => {
        if (p === window.location.pathname || window.location.pathname.match(p))
            window.goatcounter = {no_onload: true}
    })
</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