Add Privatus Analytics to VuePress
Add cookieless analytics to a VuePress 2 docs site with the head option in your config file, with route changes counted as page views automatically.
Add the script to head in .vuepress/config.js (or config.ts):
js
export default {
// ...
head: [
[
'script',
{
defer: '',
src: 'https://privatusstats.com/js/pa.js',
'data-site': 'pa_YOURSITEID',
'data-modules': 'engage,auto,vitals,clicks,ask',
},
],
],
}
Each head entry is [tagName, { attrName: attrValue }, innerHTML?] and
VuePress injects it into the <head> of the rendered HTML. The tracker URL
is absolute, so VuePress's base option does not affect it.
VuePress is a single-page app after the first load. The tracker follows its
history.pushState navigations automatically. See
single-page apps.
This page covers VuePress 2. Check your version's head docs if you use
VuePress 1.