Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Google Analytics for direct resource on Node.js_Javascript_Node.js_Google Analytics - Fatal编程技术网

Javascript Google Analytics for direct resource on 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

我正在一个网站上工作,用于托管图像,例如:。图像通过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.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这些节点模块实现了测量协议,不需要将输出发送到浏览器,例如,跟踪可以在服务器端完成。我还没有测试过自己,但可能值得一看。