文档
浏览文档

Add Privatus Analytics to Docsify

Add cookieless analytics to a Docsify docs site with one script tag in index.html, with hash routes counted as separate page views.

查看 Markdown

Docsify runs from one index.html. Add the snippet there, before the closing </body> tag and after the line that loads Docsify:

html
<script>
  window.$docsify = {
    // your config
  }
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@5"></script>
<script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>

Docsify pages are Markdown files rendered in the browser, so the whole site is one HTML page. The tracker's default data-spa="auto" keeps route fragments like #/guide/setup in the path and follows hashchange, so each Docsify page is counted. Plain anchors such as #install are not page views. If you use history mode, auto follows history.pushState as well. See single-page apps.

The tracker ignores localhost, so docsify serve is not counted.