【问题标题】:Track analytics on dropbox file downloads跟踪 Dropbox 文件下载的分析
【发布时间】:2015-11-11 17:39:14
【问题描述】:

我正在播放播客。音频在我的博客上播放,可供下载。我可以很容易地跟踪分析。目前,我还在自己的服务器上托管 mp3,因此跟踪对 mp3 本身的访问也很容易,但第一集有近 1000 次下载/收听,带宽非常高。我想将文件卸载到外部云服务,但我不知道如何跟踪播放。 iTunes 使用我提供的 XML 提要,指示文件位置、标题、描述等内容。它们不会跟踪使用数据,甚至不会为您跟踪订阅者数量。

所以我的问题是,如何跟踪对托管在云中的文件(dropbox/drive/amazon/etc)的 mp3 播放/下载的分析?我考虑过尝试像 timthumb 这样的方法,其中 url 指向带有几个 url 变量的 php 文件,服务器端脚本命中分析,然后使用 HTTP 标头提供 mp3。我只是不知道这是否可行,测试它的唯一方法是在现场播客上实际尝试它——太可怕了。

有什么想法可以为我指明正确的方向吗?我已经搜索了谷歌,但都没有找到。

提前致谢。

【问题讨论】:

    标签: php google-analytics mp3


    【解决方案1】:

    我已经想通了。方法如下:

    在我的 .htaccess 文件中,我查找 mp3 文件请求:

    RewriteRule ([^/]*)\.mp3$ audio.php/?file=$1.mp3 [QSA,L,R=301]

    感谢 dancameron (https://github.com/dancameron/server-side-google-analytics),在我的 audio.php 文件中,我使用了服务器端 Google Analytics:

    //Grab the file name
    $file = $_GET['file'];
    
    //create new ssga object
    include('/home/flightca/public_html/wp-content/themes/flightcast/lib/ss-ga.class.php');
    $ssga = new ssga( 'UA-XXXXXXXX-0', 'WEBSITE.URL' );
    
    //send to analytics as an event
    $ssga->set_event( 'Audio', 'Plays', $file, $file );
    $ssga->send();
    

    最后,在我的 audio.php 文件中,我将用户重定向到云中的文件:

    //send user to audio file in the cloud
    header("HTTP/1.1 301 Moved Permanently"); 
    header("Location: https://preferred-cnd-of-choice.com/audio/".$file);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-15
      • 2016-10-15
      • 1970-01-01
      • 2014-01-05
      • 2014-04-06
      • 1970-01-01
      • 2011-05-29
      • 2010-09-05
      相关资源
      最近更新 更多