Prefix GoatCounter paths with the host
Each language is its own host and GoatCounter stores only a path, so fr.mykiwi.blog/ and mykiwi.blog/ were the same row. The boosted-navigation call passes its path explicitly, which count.js does not run through the path callback, so it adds the host itself.
c6cef41 parent: ff80112 modified
blog/layouts/_default/baseof.html +12 -2 | @@ -344,14 +344,24 @@ | ||
| 344 | 344 | }); |
| 345 | 345 | })(); |
| 346 | 346 | </script> |
| 347 | + {{- /* GoatCounter records only a path, and every language is its own host | |
| 348 | + (fr.mykiwi.blog/ and mykiwi.blog/ would both be "/"), so the host goes | |
| 349 | + in front of it: https://www.goatcounter.com/help/domains. Must be set | |
| 350 | + before count.js runs. */}} | |
| 351 | + <script> | |
| 352 | + window.goatcounter = {path: (p) => location.host + p}; | |
| 353 | + </script> | |
| 347 | 354 | <script data-goatcounter="https://stats.mykiwi.blog/count" |
| 348 | 355 | async src="//gc.zgo.at/count.js"></script> |
| 349 | 356 | {{- /* count.js only sees the first full load; hx-boost navigations after |
| 350 | 357 | that never reload <head>, so each one is reported by hand. The initial |
| 351 | - load fires no swap event, so nothing is counted twice. */}} | |
| 358 | + load fires no swap event, so nothing is counted twice. The path is | |
| 359 | + passed explicitly (count.js would otherwise read the <link | |
| 360 | + rel="canonical"> that hx-boost left behind from the first page), and an | |
| 361 | + explicit path skips the callback above, so the host is added here. */}} | |
| 352 | 362 | <script> |
| 353 | 363 | document.addEventListener("htmx:after:swap", () => { |
| 354 | - window.goatcounter?.count?.({path: location.pathname + location.search, title: document.title}); | |
| 364 | + window.goatcounter?.count?.({path: location.host + location.pathname + location.search, title: document.title}); | |
| 355 | 365 | }); |
| 356 | 366 | </script> |
| 357 | 367 | {{ block "head" . }}{{ end }} |
| @@ -344,14 +344,24 @@ | |||
| 344 | }); | 344 | }); |
| 345 | })(); | 345 | })(); |
| 346 | </script> | 346 | </script> |
| 347 | + {{- /* GoatCounter records only a path, and every language is its own host | ||
| 348 | + (fr.mykiwi.blog/ and mykiwi.blog/ would both be "/"), so the host goes | ||
| 349 | + in front of it: https://www.goatcounter.com/help/domains. Must be set | ||
| 350 | + before count.js runs. */}} | ||
| 351 | + <script> | ||
| 352 | + window.goatcounter = {path: (p) => location.host + p}; | ||
| 353 | + </script> | ||
| 347 | <script data-goatcounter="https://stats.mykiwi.blog/count" | 354 | <script data-goatcounter="https://stats.mykiwi.blog/count" |
| 348 | async src="//gc.zgo.at/count.js"></script> | 355 | async src="//gc.zgo.at/count.js"></script> |
| 349 | {{- /* count.js only sees the first full load; hx-boost navigations after | 356 | {{- /* count.js only sees the first full load; hx-boost navigations after |
| 350 | that never reload <head>, so each one is reported by hand. The initial | 357 | that never reload <head>, so each one is reported by hand. The initial |
| 351 | - load fires no swap event, so nothing is counted twice. */}} | 358 | + load fires no swap event, so nothing is counted twice. The path is |
| 359 | + passed explicitly (count.js would otherwise read the <link | ||
| 360 | + rel="canonical"> that hx-boost left behind from the first page), and an | ||
| 361 | + explicit path skips the callback above, so the host is added here. */}} | ||
| 352 | <script> | 362 | <script> |
| 353 | document.addEventListener("htmx:after:swap", () => { | 363 | document.addEventListener("htmx:after:swap", () => { |
| 354 | - window.goatcounter?.count?.({path: location.pathname + location.search, title: document.title}); | 364 | + window.goatcounter?.count?.({path: location.host + location.pathname + location.search, title: document.title}); |
| 355 | }); | 365 | }); |
| 356 | </script> | 366 | </script> |
| 357 | {{ block "head" . }}{{ end }} | 367 | {{ block "head" . }}{{ end }} |