Javascript Google Analytics for direct resource on Node.js
我正在一个网站上工作,用于托管图像,例如:。图像通过Node.js处理,如下所示:Javascript Google Analytics for direct resource on Node.js,javascript,node.js,google-analytics,Javascript,Node.js,Google Analytics,我正在一个网站上工作,用于托管图像,例如:。图像通过Node.js处理,如下所示: // Check if image exists in cache if (fs.existsSync('cache/' + req.params.image)) { log("File exists in cache, streaming from /cache/" + req.params.image, 'INFO', ip); // Read image from cache fs
// Check if image exists in cache
if (fs.existsSync('cache/' + req.params.image)) {
log("File exists in cache, streaming from /cache/" + req.params.image, 'INFO', ip);
// Read image from cache
fs.createReadStream('cache/' + req.params.image).pipe(res);
} else {
log("File does not exist, streaming from http://i.imgur.com/" + req.params.image, 'WARN', ip);
// Pipe from Imgur to user
request(url).pipe(res);
log("Saving file to cache", 'INFO', ip);
// Pipe from Imgur to cache
request(url).pipe(fs.createWriteStream('cache/' + req.params.image));
}
我使用GA的主页,相册页面和更多,但我想能够收集分析图像直接访问。我是否可以在不向响应中添加代码的情况下调用GA t这些节点模块实现了测量协议,不需要将输出发送到浏览器,例如,跟踪可以在服务器端完成。我还没有测试过自己,但可能值得一看。