6

JS异步加载统计代码

 2 years ago
source link: https://www.iyouhun.com/post-182.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
JS异步加载统计代码 - 游魂博客-分享技术,资源共享
首页 / JS异步加载统计代码

异步加载可以有效提升网页打开速度.
建议用 https://www.jsjiami.com/ 加密本文js统计代码(推荐使用V6 最牛加密)

很简单的一段代码,记得加密一下。

加密统计代码有何意义呢? 防止一些烂人恶意,爬虫我的统计ID刷大量的垃圾搜索词!

//百度统计
var siteId = '你的百度统计ID'
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?" + siteId;
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();

//CNZZ统计
var siteId = '你的CNZZ统计ID'
var cnzzJs = document.createElement('script')
cnzzJs.type = 'text/javascript'
cnzzJs.async = true
cnzzJs.charset = 'utf-8'
cnzzJs.src = 'https://v1.cnzz.com/z_stat.php?id=' + siteId +'&web_id=' + siteId

var rootJs = document.getElementsByTagName('script')[0]
rootJs.parentNode.insertBefore(cnzzJs, rootJs)

大多数刷统计是通过你的统计id来刷的,所以已经被刷过的统计id是不可以防止的哦,需要重新获取新id才可以防止


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK