沃梦达 / 编程问答 / php问题 / 正文

如何使用 google-analytics 和 php 跟踪下载页面?

How to track a download page with google-analytics and php?(如何使用 google-analytics 和 php 跟踪下载页面?)

本文介绍了如何使用 google-analytics 和 php 跟踪下载页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 php 中有一个下载页面,在执行一些检查后返回一个文件,但不显示任何 html:

I have a download page in php that after performing some checks returns a file, without displaying any html:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=xyz.exe');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize(LOCAL_FILE));
readfile(LOCAL_FILE);

现在我想用 google-analytics 跟踪这个页面.在不显示 html 的情况下实现这一目标的最佳方法是什么?

Now I'd like to track this page with google-analytics. What's the best way to achieve this without displaying html?

推荐答案

试试这个:http://www.acleon.co.uk/posts/galvanize-google-analytics-without-the-javascript/

它叫做Galvanize"(不知道是谁想到的).您可以在此处下载该类.

Its called 'Galvanize' (Don't know who thought that one up). You can download the class here.

显然开发人员仍然支持它,因为他两天前刚刚评论了一个错误修复.

Apparently the developer is still supporting it too, as he just commented about a bug fix 2 days ago.

这篇关于如何使用 google-analytics 和 php 跟踪下载页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何使用 google-analytics 和 php 跟踪下载页面?