current practice:
put the statistical code directly in index.html;
problem: cannot count the url; during route hopping
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan style="display:none;" id="cnzz_stat_icon_1258575107"%3E%3C/span%3E%3Cscript src="" + cnzz_protocol + "s5.cnzz.com/stat.php%3Fid%3D1258575107" type="text/javascript"%3E%3C/script%3E"));</script>
vue
find a code writing method for cnzz statistics of vue on the Internet. How to write the react project?
<template>
<router-view></router-view>
</template>
<script>
export default {
name: "app",
mounted () {
const script = document.createElement("script")
script.src = "https://s95.cnzz.com/z_stat.php?id=1111111111&web_id=1111111111"
script.language = "JavaScript"
document.body.appendChild(script)
},
watch: {
"$route" () {
if (window._czc) {
let location = window.location
let contentUrl = location.pathname + location.hash
let refererUrl = "/"
window._czc.push(["_trackPageview", contentUrl, refererUrl])
}
}
}
}
</script>