[Feature Request] 增加对 umami 访问统计的支持
chitang233 opened this issue · 4 comments
chitang233 commented
YunYouJun commented
I haven't used it, and I don't know how to add parameters.
Do you want to create a PR for it?
chitang233 commented
No, I can't write themes
asadahimeka commented
@chitang233 , You can use hexo(version > 5) injector to insert the script tag like this:
// <blog_root>/scripts/injector.js
hexo.extend.injector.register('head_end', '<script async defer data-website-id="<your-website-id>" src="<your-umami-url>"></script>');
Then you can track events using CSS classes or Javascript
For example:
<button id="signup-button" class="button umami--click--signup-button">Sign up</button>
// in your custom js
function addUmamiClickEvent(sel, name) {
const el = document.querySelector(sel);
el && el.addEventListener('click', () => {
window.umami(name);
});
}
addUmamiClickEvent('#search', 'click search btn');
chitang233 commented
Thanks, that's quite useful!