Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Add fathom analytics (#200)
Browse files Browse the repository at this point in the history
Co-authored-by: Dillon <[email protected]>
  • Loading branch information
codedge and dillonzq authored Apr 21, 2020
1 parent f14301c commit a5d0b9a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ I hope you will LoveIt ❤️!
* Optimized for **performance**: 99/100 on mobile and 100/100 on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights)
* Optimized SEO performance with a correct **SEO SCHEMA** based on JSON-LD
* [**Google Analytics**](https://analytics.google.com/analytics) supported
* [**Fathom Analytics**](https://usefathom.com/) supported
* Search engine **verification** supported (Google, Bind, Yandex and Baidu)
* **CDN** for third-party libraries supported
* Automatically converted images with **Lazy Load** by [lazysizes](https://github.com/aFarkas/lazysizes)
Expand Down
5 changes: 5 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,11 @@ enableEmoji = true
yandex = ""
pinterest = ""
baidu = ""
[params.fathomAnalytics]
# siteID = "ABC123"
# If you're self hosting use this for your tracker
# serverURL = "https://example.com"

# CSS and JS Files CDN
# CSS 和 JS 文件的 CDN 设置
[params.cdn]
Expand Down
6 changes: 5 additions & 1 deletion layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,8 @@
{{- /* Google analytics async */ -}}
{{- if eq hugo.Environment "production" | and .Site.GoogleAnalytics -}}
{{- template "_internal/google_analytics_async.html" . -}}
{{- end -}}

{{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }}
{{- partial "plugin/analytics/fathom" . -}}
{{ end }}
{{- end -}}
13 changes: 13 additions & 0 deletions layouts/partials/plugin/analytics/fathom.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit a5d0b9a

Please sign in to comment.