[feat] 支持matomo网站统计

This commit is contained in:
zhangjiashu
2023-11-10 18:39:17 +08:00
parent 4c483a71fe
commit c9718f49ee
3 changed files with 37 additions and 20 deletions

View File

@@ -97,6 +97,24 @@ const CommonScript = () => {
/>
)}
{/* Matomo 统计 */}
{BLOG.MATOMO_HOST_URL && BLOG.MATOMO_SITE_ID && (
<script async dangerouslySetInnerHTML={{
__html: `
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//${BLOG.MATOMO_HOST_URL}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '${BLOG.MATOMO_SITE_ID}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
`
}}/>
)}
{/* 谷歌统计 */}
{BLOG.ANALYTICS_GOOGLE_ID && (<>
<script async