mirror of
https://github.com/two-torial/two-torial.git
synced 2026-09-10 12:07:04 -05:00
Add GoatCounter analytics
Add GoatCounter analytics
This commit is contained in:
@@ -180,6 +180,7 @@ not_in_nav: |
|
|||||||
|
|
||||||
theme:
|
theme:
|
||||||
name: material
|
name: material
|
||||||
|
custom_dir: overrides
|
||||||
logo: img/logo/website-logo.svg
|
logo: img/logo/website-logo.svg
|
||||||
favicon: img/favicon.ico
|
favicon: img/favicon.ico
|
||||||
icon:
|
icon:
|
||||||
@@ -236,4 +237,9 @@ markdown_extensions:
|
|||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- search
|
- search
|
||||||
- git-revision-date-localized
|
- git-revision-date-localized
|
||||||
|
|
||||||
|
extra:
|
||||||
|
analytics:
|
||||||
|
provider: custom
|
||||||
|
property: https://tuah-torial.goatcounter.com/count
|
||||||
|
|||||||
37
overrides/partials/integrations/analytics/custom.html
Normal file
37
overrides/partials/integrations/analytics/custom.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<script data-goatcounter="{{ config.extra.analytics.property }}"
|
||||||
|
{# We also need to disable sending a pageview on load if using instant navigation, see below. #}
|
||||||
|
{% if "navigation.instant" in config.theme.features %}
|
||||||
|
data-goatcounter-settings='{"no_onload": true}'
|
||||||
|
{% endif %}
|
||||||
|
async src="//gc.zgo.at/count.js"></script>
|
||||||
|
{#
|
||||||
|
The below code block is for handling "instant navigation" in Material MkDocs.
|
||||||
|
It is currently not applicable to us, but if we wish to switch to it in the future,
|
||||||
|
this will properly handle URL changes for analytics.
|
||||||
|
#}
|
||||||
|
{% if "navigation.instant" in config.theme.features %}
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
// GoatCounter might not load, because people might have it blocked
|
||||||
|
// from uBlock Origin or other content blockers.
|
||||||
|
if (!window.goatcounter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let referrer = document.referrer;
|
||||||
|
|
||||||
|
document$.subscribe((d) => {
|
||||||
|
// We don't need to pass the path, because when this observable is called,
|
||||||
|
// `window.location` will already be on the new path.
|
||||||
|
// We still need to manually handle referrals and site titles though.
|
||||||
|
window.goatcounter.count({
|
||||||
|
title: d.querySelector("h1")?.textContent || d.title,
|
||||||
|
referrer,
|
||||||
|
});
|
||||||
|
|
||||||
|
referrer = window.location.href;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
Reference in New Issue
Block a user