如何在ASP.NET中跟踪已完成的文件下载

时间:2021-10-07 13:52:33

I have this ASP.NET web site that allows users to download program installation packages (just normal files). I want to be able to track when a download is completed (i.e. the file has been fully downloaded to the user's computer) and then invoke a Google Analytics script that reports a completed download as a 'Goal' (obviously, one of my goals is to increase file downloads).

我有这个ASP.NET网站,允许用户下载程序安装包(只是普通文件)。我希望能够跟踪下载完成的时间(即文件已完全下载到用户的计算机),然后调用Google Analytics脚本,将完整的下载报告为“目标”(显然,我的目标之一是增加文件下载量)。

The problem is that I need to support direct file URLs, as opposed to the "redirect page" solution. This is because a lot of traffic comes from software download sites that explicitly demand a direct file URL when submitting a product. Perhaps, they do their own file analysis (i.e. virus checking). But with this set of limitations, a typical scenario is:

问题是我需要支持直接文件URL,而不是“重定向页面”解决方案。这是因为大量流量来自软件下载站点,这些站点在提交产品时明确要求直接文件URL。也许,他们进行自己的文件分析(即病毒检查)。但是有了这些限制,典型的情况是:

  1. The user visits my product listing on a software download site
  2. 用户在软件下载站点*问我的产品列表
  3. The user clicks the "Download" button on this site
  4. 用户单击此站点上的“下载”按钮
  5. The "Download" page is typically a redirect that finally brings the user to my file via the direct URL I've initially submitted, i.e. http://www.ko-sw.com/somefile.exe
  6. “下载”页面通常是一个重定向,最终通过我最初提交的直接URL将用户带到我的文件,即http://www.ko-sw.com/somefile.exe

If under these conditions, an exact solution for monitoring is not possible, maybe there exists a workaround? What comes to my mind is temporarily storing the number of performed downloads on the server and then accessing an administrative page that somehow reports this number to Google Analytics and finally sets it back to zero. With this workaround, there is at least no need to try to attach a javascript handler to a non-HTML resource. But even then there are issues:

如果在这些条件下,无法进行精确的监控解决方案,可能存在解决方法吗?我想到的是暂时在服务器上存储已执行下载的数量,然后访问管理页面,该页面以某种方式将此数字报告给Google Analytics并最终将其设置为零。通过此解决方法,至少不需要尝试将javascript处理程序附加到非HTML资源。但即便如此,也存在一些问题:

  1. How to track if a download has completed?
  2. 如何跟踪下载是否已完成?
  3. How to track user geolocation and browser capabilities to make them further visible in the reports?
  4. 如何跟踪用户地理位置和浏览器功能,使其在报告中进一步显示?

Thanks everybody in advance

提前谢谢大家

6 个解决方案

#1


8  

Better alternative: Let your installer open up a web page once the user installed the web software. Example: See the Keepass installer.

更好的选择:让用户在安装网络软件后打开网页。示例:请参阅Keepass安装程序。

You can track this opening rate in GA and get the numbers of installs.

您可以在GA中跟踪此开放率并获取安装数量。

#2


4  

According to awstats aborted download has http status code 206 so if you analyze server log for such code you can get those downloads that were not completed.

根据awstats中止下载有http状态代码206所以如果你分析服务器日志这样的代码,你可以得到那些未完成的下载。

#3


2  

@Kerido ~ I'm curious what the business case is here. Are you trying to track installs or downloads? If installs, go with @SamMeiers solution.

@Kerido~我很好奇商业案例在这里。您是否尝试跟踪安装或下载?如果安装,请使用@SamMeiers解决方案。

However, if you're trying to track downloads, then the next question is what webserver base are you using? IIS? Apache? Something else?

但是,如果您正在尝试跟踪下载,那么下一个问题是您使用的是哪个网络服务器基础? IIS? Apache的?别的什么?

In IIS, assuming you're using 7 (or later), you could (easily?) write a HttpHandler that checks for the last bytes of the file to be sent, and on that, record a log somewhere.

在IIS中,假设您正在使用7(或更高版本),您可以(轻松?)编写一个HttpHandler来检查要发送的文件的最后字节,然后在某处记录日志。

On Apache, just setup logging to tell you how many bytes were transferred (a trivial change in httpd.conf) and then parse the logs daily (awstats [amongst others] is pretty good for this, but you might have to write a sed/awk script) and find out how many full transfers were completed. Just depends on how thorough you're trying to be.

在Apache上,只需设置日志记录就可以告诉你传输了多少字节(httpd.conf中的一个微不足道的变化),然后每天解析日志(awstats [等等]对此非常有用,但你可能需要写一个sed / awk脚本)并找出完成了多少完整传输。只是取决于你想要的彻底。

But I go back to, what's the business case for this? What does it matter if there were unfinished downloads?

但我回过头来看,这是什么商业案例?如果有未完成的下载,这有什么关系?

#4


1  

This link might be able to help you:

此链接可能能够帮助您:

http://www.devx.com/dotnet/Article/22533/1954

http://www.devx.com/dotnet/Article/22533/1954

I've used it as a reference before for some of my work.

在我的一些工作之前,我已经将它作为参考。

#5


0  

It's possible to track links as a goal, which may be of use to you. However, this won't track when the download was completed. http://www.google.com/support/analytics/bin/answer.py?answer=55529

可以将链接作为目标进行跟踪,这可能对您有用。但是,这不会跟踪下载完成的时间。 http://www.google.com/support/analytics/bin/answer.py?answer=55529

Hope this helps. Cheers Tigger

希望这可以帮助。干杯跳跳虎

#6


0  

I think the solution of @SamMeiers is very good but you may optimized by calling a web services after the installation complete but you might find a small problem if the use installing the app in an environment without internet but you might force to check if there is an internet or not. You can create any trigger when you installation start as a start flag then when if finish check if the start flag exists then the app have been downloaded and installed also.

我认为@SamMeiers的解决方案非常好,但您可以通过在安装完成后调用Web服务进行优化,但如果在没有Internet的环境中安装应用程序,您可能会发现一个小问题但是您可能会强制检查是否存在互联网与否。您可以在安装开始时作为开始标志创建任何触发器,然后在完成时检查是否存在开始标志,那么应用程序也已下载并安装。

#1


8  

Better alternative: Let your installer open up a web page once the user installed the web software. Example: See the Keepass installer.

更好的选择:让用户在安装网络软件后打开网页。示例:请参阅Keepass安装程序。

You can track this opening rate in GA and get the numbers of installs.

您可以在GA中跟踪此开放率并获取安装数量。

#2


4  

According to awstats aborted download has http status code 206 so if you analyze server log for such code you can get those downloads that were not completed.

根据awstats中止下载有http状态代码206所以如果你分析服务器日志这样的代码,你可以得到那些未完成的下载。

#3


2  

@Kerido ~ I'm curious what the business case is here. Are you trying to track installs or downloads? If installs, go with @SamMeiers solution.

@Kerido~我很好奇商业案例在这里。您是否尝试跟踪安装或下载?如果安装,请使用@SamMeiers解决方案。

However, if you're trying to track downloads, then the next question is what webserver base are you using? IIS? Apache? Something else?

但是,如果您正在尝试跟踪下载,那么下一个问题是您使用的是哪个网络服务器基础? IIS? Apache的?别的什么?

In IIS, assuming you're using 7 (or later), you could (easily?) write a HttpHandler that checks for the last bytes of the file to be sent, and on that, record a log somewhere.

在IIS中,假设您正在使用7(或更高版本),您可以(轻松?)编写一个HttpHandler来检查要发送的文件的最后字节,然后在某处记录日志。

On Apache, just setup logging to tell you how many bytes were transferred (a trivial change in httpd.conf) and then parse the logs daily (awstats [amongst others] is pretty good for this, but you might have to write a sed/awk script) and find out how many full transfers were completed. Just depends on how thorough you're trying to be.

在Apache上,只需设置日志记录就可以告诉你传输了多少字节(httpd.conf中的一个微不足道的变化),然后每天解析日志(awstats [等等]对此非常有用,但你可能需要写一个sed / awk脚本)并找出完成了多少完整传输。只是取决于你想要的彻底。

But I go back to, what's the business case for this? What does it matter if there were unfinished downloads?

但我回过头来看,这是什么商业案例?如果有未完成的下载,这有什么关系?

#4


1  

This link might be able to help you:

此链接可能能够帮助您:

http://www.devx.com/dotnet/Article/22533/1954

http://www.devx.com/dotnet/Article/22533/1954

I've used it as a reference before for some of my work.

在我的一些工作之前,我已经将它作为参考。

#5


0  

It's possible to track links as a goal, which may be of use to you. However, this won't track when the download was completed. http://www.google.com/support/analytics/bin/answer.py?answer=55529

可以将链接作为目标进行跟踪,这可能对您有用。但是,这不会跟踪下载完成的时间。 http://www.google.com/support/analytics/bin/answer.py?answer=55529

Hope this helps. Cheers Tigger

希望这可以帮助。干杯跳跳虎

#6


0  

I think the solution of @SamMeiers is very good but you may optimized by calling a web services after the installation complete but you might find a small problem if the use installing the app in an environment without internet but you might force to check if there is an internet or not. You can create any trigger when you installation start as a start flag then when if finish check if the start flag exists then the app have been downloaded and installed also.

我认为@SamMeiers的解决方案非常好,但您可以通过在安装完成后调用Web服务进行优化,但如果在没有Internet的环境中安装应用程序,您可能会发现一个小问题但是您可能会强制检查是否存在互联网与否。您可以在安装开始时作为开始标志创建任何触发器,然后在完成时检查是否存在开始标志,那么应用程序也已下载并安装。