diff options
author | Kellen <root@goodroot.ca> | 2020-12-13 05:14:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-13 05:14:32 +0300 |
commit | bfac4c0a750e29db43fabff5bbbe6be9d1264f1d (patch) | |
tree | 61cfcaf9fd829093790b0a8f6b974878196cea7a | |
parent | 927fce272ef6449c29760495fab34855fe0bc4cb (diff) | |
parent | a7f29151e81fd843ec6a56f7d1a2de57365115c6 (diff) |
Merge pull request #12 from christianboyle/add_fathom_analytics
Add support for Fathom Analytics
-rw-r--r-- | exampleSite/config.toml | 7 | ||||
-rw-r--r-- | layouts/partials/analytics/fathom.html | 13 | ||||
-rw-r--r-- | layouts/partials/footer.html | 3 |
3 files changed, 23 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index f546f66..6af5db1 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -26,3 +26,10 @@ footnotereturnlinkcontents = "↩" description = "A simple, minimal blog for those who love text." footer = "Open-Source | [Github](https://github.com/goodroot/hugo-classic) | [Keybase](https://keybase.io/goodroot)" custom_css = ["css/theme-override.css"] + +# If you want to use Fathom (https://usefathom.com) for analytics, add this section +[params.fathomAnalytics] + siteID = "ABCDE" + # Default value is cdn.usefathom.com, overwrite this if you are self-hosting + serverURL = "analytics.example.com" + diff --git a/layouts/partials/analytics/fathom.html b/layouts/partials/analytics/fathom.html new file mode 100644 index 0000000..13e7cfc --- /dev/null +++ b/layouts/partials/analytics/fathom.html @@ -0,0 +1,13 @@ +<script> +(function(f, a, t, h, o, m){ + a[h]=a[h]||function(){ + (a[h].q=a[h].q||[]).push(arguments) + }; + o=f.createElement('script'), + m=f.getElementsByTagName('script')[0]; + o.async=1; o.src=t; o.id='fathom-script'; + m.parentNode.insertBefore(o,m) +})(document, window, '//{{ .Site.Params.fathomAnalytics.serverURL | default "cdn.usefathom.com" }}/tracker.js', 'fathom'); +fathom('set', 'siteId', '{{ .Site.Params.fathomAnalytics.siteID }}'); +fathom('trackPageview'); +</script> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 0a6c3f0..57ef8f3 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -5,5 +5,8 @@ {{ . | markdownify }} {{ end }} </footer> + {{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }} + {{- partial "analytics/fathom" . -}} + {{ end }} </body> </html> |