我如何跟踪远程网站文件的下载 [英] How can I track downloads of files from remote websites

查看:113
本文介绍了我如何跟踪远程网站文件的下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分享存储在我的服务器中的文件链接(例如pdf)。只要有用户下载文件,是否可以跟踪?我没有访问其他页面的脚本,但我想我可以跟踪到我的服务器的传入请求。这会是计算上的昂贵吗?你可以使用 com / analytics / devguides / collection / protocol / v1 /rel =nofollow noreferrer>测量协议,这是对Google Analytics(分析)跟踪服务器的http跟踪请求的语言不可知说明。

您的情况的问题在于您没有在点击和下载之间发送跟踪请求的脚本。一个可能的解决方法是使用服务器访问日志,只要你有一些控制服务器。

://httpd.apache.org/docs/2.4/logs.html#pipedrel =nofollow noreferrer>管道日志,例如相反,如果直接写入文件,日志条目将传递给脚本或程序。我相当肯定其他服务器有类似的东西。



您可以将日志传送到一个脚本,该脚本评估日志条目是否指向您的pdf文件的URL,如果这样的话将信息分解成单独的数据字段并通过您选择的编程语言将它们发送到GA跟踪服务器。



如果您无法将服务器控制到该级别,则需要在服务器上放置与原始文件具有相同名称和位置的脚本,将pdf扩展名到您选择的脚本解释器(在apache中通过 addType ,它可以通过一个htaccess文件来完成,并且让脚本在发送原始文件之前发送跟踪请求。

这两种解决方案都需要一定程度的编程实践(后者比前者少得多)。根据对服务器的请求数量,管道日志可能非常昂贵(尽管如此,您也可以为可下载的文件创建额外的日志文件)。中介脚本不会是一个昂贵的操作。


I am sharing the link of a file (e.g. pdf), which is stored in my server. Is it possible to track whenever some user is downloading the file? I don't have access to the script of the other page but I thought I could track the incoming requests to my server. Would that be computationally expensive? Any hints towards which direction to look?

解决方案

You can use the measurement protocol, a language agnostic description of a http tracking request to the Google Analytics tracking server.

The problem in your case is that you do not have a script between the click and the download to send the tracking request. One possible workaround would be to use the server access log, provided you have some control over the server.

For example the Apache web server can user piped logs, e.g. instead if being written directly to a file the log entry is passed to a script or program. I'm reasonably sure that other servers have something similar.

You could pipe the logs to a script that evaluates if the log entry points at the URL of your pdf file, and if so breaks down the info into individual data fields and sends them via a programming language of your choice to the GA tracking server.

If you cannot control the server to that level you'd need to place a script with the same name and location as the original file on the server, map the pdf extension to a script interpreter of your choice (in apache via addType, which with many hosts can be done via a htaccess file) and have the script sending the tracking request before delivering the original file.

Both solutions require a modicum of programming practice (the latter much less than the former). Piping logs might be expensive, depending on the number of requests to your server (you might create an extra log file for downloadable files, though). An intermediary script would not be an expensive operation.

这篇关于我如何跟踪远程网站文件的下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆