3zz*_*zzy 3 javascript analytics google-analytics
我需要开发一个内部实时分析解决方案(例如类似于 GA 或 mixpanel)来收集:
\n\n.. 并通过单像素图像请求将此数据发送到服务器。与 GA 和其他解决方案的工作原理类似:
\n\n\n\n\nGoogle Analytics(分析)的工作原理是在您网站的页面上包含一段 JavaScript 代码。当您网站的用户查看页面时,此 JavaScript 代码会引用JavaScript 文件,然后该文件执行Analytics 的跟踪操作。跟踪操作通过各种方式检索有关页面请求的数据,并通过附加到单像素图像请求的参数列表将此信息发送到分析服务器。
\n
我想知道是否有任何开源项目可以完成这部分工作,我可以将其用作进一步构建的基础。但它Piwik
的功能太丰富,而且对于我的要求来说太重了。
编辑添加:我正在对数据做一些特定的事情,否则我只会使用现有的解决方案。
\n尝试
var img = new Image;
img.width = img.height = "1px";
var res = window.navigator;
var data = {};
var _plugins = {};
Array.prototype.slice.call(navigator.plugins).forEach(function(v, k) {
_plugins[v.name.toLowerCase().replace(/\s/, "-")] = {
"name": v.name,
"description": v.description,
"filename": v.filename
}
});
delete res.plugins && delete res.mimeTypes;
data.url = window.location.href;
data.ref = document.referrer;
data.nav = res;
data._plugins = _plugins;
// set `img` `dataset` with `data` ,
// send `img` to server , decode `img` `dataset` at server
img.dataset.stats = JSON.stringify(data);
Run Code Online (Sandbox Code Playgroud)
var img = new Image;
img.width = img.height = "1px";
var res = window.navigator;
var data = {};
var _plugins = {};
Array.prototype.slice.call(navigator.plugins).forEach(function(v, k) {
_plugins[v.name.toLowerCase().replace(/\s/, "-")] = {
"name": v.name,
"description": v.description,
"filename": v.filename
}
});
delete res.plugins && delete res.mimeTypes;
data.url = window.location.href;
data.ref = document.referrer;
data.nav = res;
data._plugins = _plugins;
// set `img` `dataset` with `data` ,
// send `img` to server , decode `img` `dataset` at server
img.dataset.stats = JSON.stringify(data);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4989 次 |
最近记录: |