公司要做一个流量统计,怎么统计一篇文章,的信息。像中国网,网站的栏目下很多文章。怎么统计文章的编辑是谁,还有来源等信息。js怎么实现嵌入。
你是要统计自己站点下的文章的编辑呢,还是去统计第三王站点(如中国网)下的文章的信息呢
第三方的
var req; var visitID; function creatReq() { //获取当前网站的根目录,全剧通用的保证 var path = getRootPath(); var url = path + "AjaxHandler.ashx"; if (window.XMLHttpRequest) { req = new XMLHttpRequest; } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHttp"); } if (req) { // alert(1) //获得当前的网址 var link = window.location.href; //获取上页地址 var oldlink = document.referrer; //获得当前访问页标题 var titleName = document.title; //获得屏幕分辨率 var screen = window.screen.width + "*" + window.screen.height; //异步请求 req.open("GET", url + "?id=" + escape(link) + "&oldlink=" + escape(oldlink) + "&title=" + escape(titleName) + "&sys=" + getSysInfo() + "&s=" + screen + "&b=" + GetBrowserType() + " " + GetBrowserVersion() + "&p=" + remote_ip_info.province + "&c=" + remote_ip_info.city + "&k=" + GetKeyword(oldlink), false); req.onreadystatechange = callback; //定制回调函数 req.send(); } } //获取网站的根目录,这个比较重要 function getRootPath() { return window.location.protocol + "//" + window.location.host + "/" } //获取来自搜索引擎的关键字 function GetKeyword(url) { if (url.toString().indexOf("baidu") > 0) { return request(url, "wd") } else if (url.toString().indexOf("sogou") > 0) { return request(url, "query") } else if (url.toString().indexOf("google") > 0) { return request(url, "q"); } else if (url.toString().indexOf("soso") > 0) { return request(url, "w") } else { return ""; } } //获取链接地址中某个参数的值 function request(url, paras) { var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&"); var paraObj = {} for (i = 0; j = paraString[i]; i++) { paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length); } var returnValue = paraObj[paras.toLowerCase()]; if (typeof (returnValue) == "undefined") { return ""; } else { return returnValue; } } //回调函数,可以获取添加后访问ID,一边操作。 function callback() { if (req.readyState == 4) { if (req.status == 200) { visitID = req.responseText; alert(visitID) if (visitID == 1) { alert("成功获取") } } else { } } else { } } //获取系统信息 function getSysInfo() { var ua = navigator.userAgent.toLowerCase(); isWin7 = ua.indexOf("nt 6.1") > -1 isVista = ua.indexOf("nt 6.0") > -1 isWin2003 = ua.indexOf("nt 5.2") > -1 isWinXp = ua.indexOf("nt 5.1") > -1 isWin2000 = ua.indexOf("nt 5.0") > -1 isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1) isLinux = (ua.indexOf("linux") != -1) var broser = ""; if (isWin7) { sys = "Windows 7"; } else if (isVista) { sys = "Vista"; } else if (isWinXp) { sys = "Windows xp"; } else if (isWin2003) { sys = "Windows 2003"; } else if (isWin2000) { sys = "Windows 2000"; } else if (isWindows) { sys = "Windows"; } else if (isMac) { sys = "Macintosh"; } else if (isAir) { sys = "Adobeair"; } else if (isLinux) { sys = "Linux"; } else { sys = "Unknow"; } return sys; } //获得浏览器类型 function GetBrowserType() { var ua = navigator.userAgent.toLowerCase(); if (ua == null) return "ie" else if (ua.indexOf('chrome') != -1) return "chrome" else if (ua.indexOf('opera') != -1) return "opera"; else if (ua.indexOf('msie') != -1) return "ie"; else if (ua.indexOf('safari') != -1) return "safari"; else if (ua.indexOf('firefox') != -1) return "firefox"; else if (ua.indexOf('gecko') != -1) return "gecko"; else return "ie"; } //获取浏览器版本 function GetBrowserVersion() { var ua = navigator.userAgent.toLowerCase(); if (ua == null) return "null"; else if (ua.indexOf('chrome') != -1) return ua.substring(ua.indexOf('chrome') + 7, ua.length).split(' ')[0]; else if (ua.indexOf('opera') != -1) return ua.substring(ua.indexOf('version') + 8, ua.length); else if (ua.indexOf('msie') != -1) return ua.substring(ua.indexOf('msie') + 5, ua.length - 1).split(';')[0]; else if (ua.indexOf('safari') != -1) return ua.substring(ua.indexOf('safari') + 7, ua.length); else if (ua.indexOf('gecko') != -1) return ua.substring(ua.indexOf('firefox') + 8, ua.length); else return "null"; }