Use navigator.sendBeacon

You can use navigator.sendBeacon() with GoatCounter, for example to send events when someone closes a page:

    document.addEventListener('visibilitychange', function(e) {
        if (document.visibilityState !== 'hidden')

        if (goatcounter.filter())
            event: true,
            path: function(p) { return 'unload-' + p },
<script data-goatcounter=""
        async src="//"></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