arp242 / goatcounter

Easy web analytics. No tracking of personal data.
https://www.goatcounter.com
Other
4.6k stars 191 forks source link

Help / Question: Self-hosting count.js #776

Open vivekragunathan opened 2 weeks ago

vivekragunathan commented 2 weeks ago

I am trying to self-host count.js based on this documentation: https://rms.goatcounter.com/help/countjs-host

... where it says

To host count.js somewhere else just copy it from https://gc.zgo.at/count.js and adjust the URL in data-goatcounter.

If i use the self-hosted (relative url) for the data-goatcounter, what would the src be in

<script data-goatcounter="/scripts/count.js"
          src="????"></script>
jkseppan commented 1 week ago

The src attribute is just the standard attribute that specifies the URL of the script to load, so you'd put the location of your copy of count.js there. The data-goatcounter attribute is where Goatcounter should send the pageview data.

rudeyak commented 2 days ago

Along the same lines... is there support for self-hosting at something other than the root of a web host, i.e. at https://my.host.com/goatcounter/...? I have an nginx setup and I'm reverse-proxying the traffic to the goatcounter listener (which was passed -tls proxy on the command line) with some rewrites and I can see the requests for the counter flowing in debug mode. However, there are certain site assets (e.g. /pikaday.css) that get served up with an absolute URL by the server binary. Can that behavior be modified or configurable?

rudeyak commented 2 days ago

Feels like there's a possible way to address this in serve.go, where domainStatic gets set... if that could safely have a URL and not just a hostname, that could open up the variable that gets expanded as {{.Static}} when those other links get generated?!

jkseppan commented 1 day ago

There is -base-path introduced in https://github.com/arp242/goatcounter/commit/f41329929417eb05444d94dd05f59bed07079ee3 which doesn't seem to be part of a released version yet.

rudeyak commented 1 day ago

Ooooh! That works!! So well ♥️